graphql 1.9.13 → 1.9.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47b6474c73ea5544cd3abc58bb77c9c76ef43d6456f3169eaf0b9f1047e74ff4
4
- data.tar.gz: 44b1af893736e6a7e7ef6f01ff2ef355494846b9899b9f7dcc2859f913e17884
3
+ metadata.gz: 23da143cfa3964ded042927d8b52fa98598387b3ab471b2ae66a2d25282af9b4
4
+ data.tar.gz: e1a2924a847a05c1214b350bb316f093ab36a09b4be20c7e4cb66a2ee429058f
5
5
  SHA512:
6
- metadata.gz: bda09371e97f5f0530e298a1ce373822031362405697137a02361e3f4abb955cb44c5dd47b2c16deea91b893db29531b400c20ffb480c8a9cf4606f70232e1da
7
- data.tar.gz: a5a9b8547e68f50df8d632b786ff48fd9c3bbb2670b79d3e7a401d2287fdea30d6ef29fd2ee44d78c043dd230a3a95b0d888723947cf0bd35a29a9c40e23f890
6
+ metadata.gz: c354cc5db0bf2072f25adb3798c90e011b9998cbb287ec825bdcc2f4733070af552810e28e46045b0eace05b9c8db571823a84be5e770c0be76eeb44dcd499fd
7
+ data.tar.gz: 8d7d75c3dfa2b001e36d30554eaf313b3f489625519462e53fa7c479a1f0baf4fc7d4c27aec8cc78ceb9ef28dd7182bae61a6c2c768e8a30915657379c2832c7
@@ -1,4 +1,9 @@
1
1
  class GraphqlController < ApplicationController
2
+ # If accessing from outside this domain, nullify the session
3
+ # This allows for outside API access while preventing CSRF attacks,
4
+ # but you'll have to authenticate your user separately
5
+ protect_from_forgery with: :null_session
6
+
2
7
  def execute
3
8
  variables = ensure_hash(params[:variables])
4
9
  query = params[:query]
@@ -402,12 +402,12 @@ module GraphQL
402
402
  @interpreter_context[:current_field] = field
403
403
  # Wrap the execution of _this_ method with tracing,
404
404
  # but don't wrap the continuation below
405
- inner_obj = query.trace("execute_field_lazy", {owner: owner, field: field, path: path, query: query, object: owner_object, arguments: arguments}) do
406
- begin
405
+ inner_obj = begin
406
+ query.trace("execute_field_lazy", {owner: owner, field: field, path: path, query: query, object: owner_object, arguments: arguments}) do
407
407
  schema.sync_lazy(lazy_obj)
408
+ end
408
409
  rescue GraphQL::ExecutionError, GraphQL::UnauthorizedError => err
409
410
  yield(err)
410
- end
411
411
  end
412
412
  after_lazy(inner_obj, owner: owner, field: field, path: path, owner_object: owner_object, arguments: arguments, eager: eager) do |really_inner_obj|
413
413
  yield(really_inner_obj)
@@ -118,6 +118,8 @@ module GraphQL
118
118
  ruby_kwargs
119
119
  end
120
120
 
121
+ alias :to_hash :to_kwargs
122
+
121
123
  private
122
124
 
123
125
  class ArgumentValue
@@ -60,7 +60,9 @@ module GraphQL
60
60
 
61
61
  # Return the GraphQL schema string for the introspection type system
62
62
  def self.print_introspection_schema
63
- query_root = ObjectType.define(name: "Root")
63
+ query_root = ObjectType.define(name: "Root") do
64
+ field :throwaway_field, types.String
65
+ end
64
66
  schema = GraphQL::Schema.define(query: query_root)
65
67
 
66
68
  introspection_schema_ast = GraphQL::Language::DocumentFromSchemaDefinition.new(
@@ -77,6 +77,18 @@ module GraphQL
77
77
  }
78
78
  end
79
79
 
80
+ def self.count_at_least(item_name, minimum_count, get_items_proc)
81
+ ->(type) {
82
+ items = get_items_proc.call(type)
83
+
84
+ if items.size < minimum_count
85
+ "#{type.name} must define at least #{minimum_count} #{item_name}. #{items.size} defined."
86
+ else
87
+ nil
88
+ end
89
+ }
90
+ end
91
+
80
92
  def self.assert_named_items_are_valid(item_name, get_items_proc)
81
93
  ->(type) {
82
94
  items = get_items_proc.call(type)
@@ -92,7 +104,9 @@ module GraphQL
92
104
  }
93
105
  end
94
106
 
107
+ HAS_AT_LEAST_ONE_FIELD = Rules.count_at_least("field", 1, ->(type) { type.all_fields })
95
108
  FIELDS_ARE_VALID = Rules.assert_named_items_are_valid("field", ->(type) { type.all_fields })
109
+ HAS_AT_LEAST_ONE_ARGUMENT = Rules.count_at_least("argument", 1, ->(type) { type.arguments })
96
110
 
97
111
  HAS_ONE_OR_MORE_POSSIBLE_TYPES = ->(type) {
98
112
  type.possible_types.length >= 1 ? nil : "must have at least one possible type"
@@ -260,11 +274,13 @@ module GraphQL
260
274
  Rules::DESCRIPTION_IS_STRING_OR_NIL,
261
275
  ],
262
276
  GraphQL::ObjectType => [
277
+ Rules::HAS_AT_LEAST_ONE_FIELD,
263
278
  Rules.assert_property_list_of(:interfaces, GraphQL::InterfaceType),
264
279
  Rules::FIELDS_ARE_VALID,
265
280
  Rules::INTERFACES_ARE_IMPLEMENTED,
266
281
  ],
267
282
  GraphQL::InputObjectType => [
283
+ Rules::HAS_AT_LEAST_ONE_ARGUMENT,
268
284
  Rules::ARGUMENTS_ARE_STRING_TO_ARGUMENT,
269
285
  Rules::ARGUMENTS_ARE_VALID,
270
286
  ],
@@ -4,6 +4,7 @@ require "graphql/types/big_int"
4
4
  require "graphql/types/float"
5
5
  require "graphql/types/id"
6
6
  require "graphql/types/int"
7
+ require "graphql/types/iso_8601_date"
7
8
  require "graphql/types/iso_8601_date_time"
8
9
  require "graphql/types/json"
9
10
  require "graphql/types/string"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.9.13"
3
+ VERSION = "1.9.14"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.13
4
+ version: 1.9.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips