graphql 0.19.3 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/max_query_complexity.rb +1 -1
  3. data/lib/graphql/analysis/max_query_depth.rb +1 -1
  4. data/lib/graphql/boolean_type.rb +2 -2
  5. data/lib/graphql/define/instance_definable.rb +2 -2
  6. data/lib/graphql/enum_type.rb +3 -3
  7. data/lib/graphql/field.rb +6 -6
  8. data/lib/graphql/float_type.rb +2 -2
  9. data/lib/graphql/id_type.rb +2 -2
  10. data/lib/graphql/input_object_type.rb +1 -1
  11. data/lib/graphql/int_type.rb +2 -2
  12. data/lib/graphql/internal_representation/rewrite.rb +12 -12
  13. data/lib/graphql/introspection/arguments_field.rb +1 -1
  14. data/lib/graphql/introspection/enum_value_type.rb +1 -1
  15. data/lib/graphql/introspection/enum_values_field.rb +1 -1
  16. data/lib/graphql/introspection/field_type.rb +1 -1
  17. data/lib/graphql/introspection/fields_field.rb +1 -1
  18. data/lib/graphql/introspection/input_fields_field.rb +1 -1
  19. data/lib/graphql/introspection/input_value_type.rb +2 -2
  20. data/lib/graphql/introspection/interfaces_field.rb +1 -1
  21. data/lib/graphql/introspection/of_type_field.rb +1 -1
  22. data/lib/graphql/introspection/possible_types_field.rb +1 -1
  23. data/lib/graphql/introspection/schema_field.rb +1 -1
  24. data/lib/graphql/introspection/schema_type.rb +5 -5
  25. data/lib/graphql/introspection/type_by_name_field.rb +1 -1
  26. data/lib/graphql/introspection/type_type.rb +6 -6
  27. data/lib/graphql/introspection/typename_field.rb +1 -1
  28. data/lib/graphql/language.rb +1 -0
  29. data/lib/graphql/language/comments.rb +44 -0
  30. data/lib/graphql/language/definition_slice.rb +1 -1
  31. data/lib/graphql/language/generation.rb +35 -12
  32. data/lib/graphql/language/lexer.rb +29 -10
  33. data/lib/graphql/language/lexer.rl +25 -6
  34. data/lib/graphql/language/nodes.rb +30 -23
  35. data/lib/graphql/language/parser.rb +33 -14
  36. data/lib/graphql/language/parser.y +33 -14
  37. data/lib/graphql/language/parser_tests.rb +86 -2
  38. data/lib/graphql/language/token.rb +3 -2
  39. data/lib/graphql/language/visitor.rb +3 -3
  40. data/lib/graphql/object_type.rb +1 -1
  41. data/lib/graphql/query/arguments.rb +23 -2
  42. data/lib/graphql/query/serial_execution/field_resolution.rb +31 -14
  43. data/lib/graphql/relay/base_connection.rb +1 -3
  44. data/lib/graphql/relay/connection_type.rb +1 -1
  45. data/lib/graphql/relay/mutation.rb +1 -1
  46. data/lib/graphql/relay/relation_connection.rb +7 -3
  47. data/lib/graphql/scalar_type.rb +1 -1
  48. data/lib/graphql/schema.rb +19 -8
  49. data/lib/graphql/schema/loader.rb +2 -2
  50. data/lib/graphql/schema/printer.rb +63 -8
  51. data/lib/graphql/schema/timeout_middleware.rb +11 -11
  52. data/lib/graphql/schema/validation.rb +12 -12
  53. data/lib/graphql/static_validation/arguments_validator.rb +1 -1
  54. data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
  55. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
  56. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +1 -1
  57. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  58. data/lib/graphql/static_validation/rules/fields_will_merge.rb +3 -2
  59. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
  60. data/lib/graphql/static_validation/rules/fragment_types_exist.rb +1 -1
  61. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +9 -4
  62. data/lib/graphql/static_validation/rules/fragments_are_named.rb +1 -1
  63. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
  64. data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -3
  65. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
  66. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +2 -2
  67. data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
  68. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
  69. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +2 -2
  70. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
  71. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -6
  72. data/lib/graphql/static_validation/type_stack.rb +2 -2
  73. data/lib/graphql/string_type.rb +2 -2
  74. data/lib/graphql/version.rb +1 -1
  75. data/readme.md +1 -1
  76. data/spec/graphql/analysis/analyze_query_spec.rb +3 -3
  77. data/spec/graphql/analysis/query_complexity_spec.rb +7 -7
  78. data/spec/graphql/introspection/directive_type_spec.rb +2 -2
  79. data/spec/graphql/introspection/introspection_query_spec.rb +26 -26
  80. data/spec/graphql/language/generation_spec.rb +137 -53
  81. data/spec/graphql/language/lexer_spec.rb +22 -0
  82. data/spec/graphql/language/visitor_spec.rb +6 -6
  83. data/spec/graphql/query/arguments_spec.rb +45 -1
  84. data/spec/graphql/query/context_spec.rb +4 -4
  85. data/spec/graphql/query/executor_spec.rb +1 -1
  86. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +1 -1
  87. data/spec/graphql/relay/mutation_spec.rb +2 -2
  88. data/spec/graphql/relay/node_spec.rb +2 -2
  89. data/spec/graphql/relay/relation_connection_spec.rb +16 -0
  90. data/spec/graphql/schema/loader_spec.rb +2 -2
  91. data/spec/graphql/schema/middleware_chain_spec.rb +6 -6
  92. data/spec/graphql/schema/printer_spec.rb +268 -18
  93. data/spec/graphql/schema/rescue_middleware_spec.rb +1 -1
  94. data/spec/graphql/schema/timeout_middleware_spec.rb +2 -2
  95. data/spec/graphql/schema_spec.rb +2 -2
  96. data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +13 -0
  97. data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +1 -1
  98. data/spec/graphql/static_validation/type_stack_spec.rb +1 -1
  99. data/spec/support/dairy_app.rb +25 -25
  100. data/spec/support/dairy_data.rb +2 -0
  101. data/spec/support/star_wars_data.rb +2 -1
  102. data/spec/support/star_wars_schema.rb +18 -18
  103. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49959ced421e4d175a2ab09abb1f70046fbeecc0
4
- data.tar.gz: e9eb998841dff1511ea8d06f6482d779e39c0d4c
3
+ metadata.gz: d3f2d2dc23cdfa7b6f59817c772e9cbbc8929447
4
+ data.tar.gz: 0146b502d79a48556674a21a611abc6ea37c8519
5
5
  SHA512:
6
- metadata.gz: 8f595c5ff5a2b3062f17ec9bb038de9f2cffb550308a34a61cd8ab7c3f65a5cb878c557ebcc0aa50c31c48808be1a5a4d61ec6d609be7a14b62044809b5d4c46
7
- data.tar.gz: 1a0452062ac5a5de8ef7102d28d2c1395e1e1cc16a379c87e844c35d6f7beaa3b036932695a8a55c506218185a05aa15425820fe34ef0a428e54ae95e828305c
6
+ metadata.gz: 145639836758f14f8e9d44aebe76d1309de31f59f86297122c267c1e7e5ab2b0a422a7b739977d63f81717da188cba2aec0bf68848139b1056f01904a58692c2
7
+ data.tar.gz: ee6cb851183047974482f5e5d8da78c3e822d008cfbae67669e6938f1dcbfb10eec45e979155ec00e775e560892d9b94c461fe42dcd81ab6670c14b606eecefb
@@ -11,7 +11,7 @@ module GraphQL
11
11
  #
12
12
  class MaxQueryComplexity < GraphQL::Analysis::QueryComplexity
13
13
  def initialize(max_complexity)
14
- disallow_excessive_complexity = -> (query, complexity) {
14
+ disallow_excessive_complexity = ->(query, complexity) {
15
15
  if complexity > max_complexity
16
16
  GraphQL::AnalysisError.new("Query has complexity of #{complexity}, which exceeds max complexity of #{max_complexity}")
17
17
  else
@@ -11,7 +11,7 @@ module GraphQL
11
11
  #
12
12
  class MaxQueryDepth < GraphQL::Analysis::QueryDepth
13
13
  def initialize(max_depth)
14
- disallow_excessive_depth = -> (query, depth) {
14
+ disallow_excessive_depth = ->(query, depth) {
15
15
  if depth > max_depth
16
16
  GraphQL::AnalysisError.new("Query has depth of #{depth}, which exceeds max depth of #{max_depth}")
17
17
  else
@@ -2,6 +2,6 @@ GraphQL::BOOLEAN_TYPE = GraphQL::ScalarType.define do
2
2
  name "Boolean"
3
3
  description "Represents `true` or `false` values."
4
4
 
5
- coerce_input -> (value) { (value == true || value == false) ? value : nil }
6
- coerce_result -> (value) { !!value }
5
+ coerce_input ->(value) { (value == true || value == false) ? value : nil }
6
+ coerce_result ->(value) { !!value }
7
7
  end
@@ -25,7 +25,7 @@ module GraphQL
25
25
  # # These attrs will be defined with plain setters, `{attr}=`
26
26
  # :make, :model,
27
27
  # # This attr has a custom definition which applies the config to the target
28
- # doors: -> (car, doors_count) { doors_count.times { car.doors << Door.new } }
28
+ # doors: ->(car, doors_count) { doors_count.times { car.doors << Door.new } }
29
29
  # )
30
30
  #
31
31
  # def initialize
@@ -85,7 +85,7 @@ module GraphQL
85
85
  # make sure the previous definition_proc was executed:
86
86
  ensure_defined
87
87
 
88
- @definition_proc = -> (obj) {
88
+ @definition_proc = ->(obj) {
89
89
  kwargs.each do |keyword, value|
90
90
  public_send(keyword, value)
91
91
  end
@@ -28,7 +28,7 @@ module GraphQL
28
28
  # @example Defining an enum input
29
29
  # field :coders, types[CoderType] do
30
30
  # argument :knowing, types[LanguageType]
31
- # resolve -> (obj, args, ctx) {
31
+ # resolve ->(obj, args, ctx) {
32
32
  # Coder.where(language: args[:knowing])
33
33
  # }
34
34
  # end
@@ -51,7 +51,7 @@ module GraphQL
51
51
  #
52
52
  # # Now, resolve functions will receive `:rb` instead of `"RUBY"`
53
53
  # field :favoriteLanguage, LanguageEnum
54
- # resolve -> (obj, args, ctx) {
54
+ # resolve ->(obj, args, ctx) {
55
55
  # args[:favoriteLanguage] # => :rb
56
56
  # }
57
57
  #
@@ -91,7 +91,7 @@ module GraphQL
91
91
  result = GraphQL::Query::InputValidationResult.new
92
92
 
93
93
  if !@values_by_name.key?(value_name)
94
- result.add_problem("Expected #{JSON.dump(value_name)} to be one of: #{@values_by_name.keys.join(', ')}")
94
+ result.add_problem("Expected #{JSON.generate(value_name, quirks_mode: true)} to be one of: #{@values_by_name.keys.join(', ')}")
95
95
  end
96
96
 
97
97
  result
data/lib/graphql/field.rb CHANGED
@@ -55,7 +55,7 @@ module GraphQL
55
55
  # @example Create a field with an argument
56
56
  # field :students, types[StudentType] do
57
57
  # argument :grade, types.Int
58
- # resolve -> (obj, args, ctx) {
58
+ # resolve ->(obj, args, ctx) {
59
59
  # Student.where(grade: args[:grade])
60
60
  # }
61
61
  # end
@@ -66,7 +66,7 @@ module GraphQL
66
66
  # field :events, types[EventType] do
67
67
  # # by default, don't include past events
68
68
  # argument :includePast, types.Boolean, default_value: false
69
- # resolve -> (obj, args, ctx) {
69
+ # resolve ->(obj, args, ctx) {
70
70
  # args[:includePast] # => false if no value was provided in the query
71
71
  # # ...
72
72
  # }
@@ -95,14 +95,14 @@ module GraphQL
95
95
  #
96
96
  # # Or inside the block:
97
97
  # field :expensive_calculation_2, !types.Int do
98
- # complexity -> (ctx, args, child_complexity) { ctx[:current_user].staff? ? 0 : 10 }
98
+ # complexity ->(ctx, args, child_complexity) { ctx[:current_user].staff? ? 0 : 10 }
99
99
  # end
100
100
  #
101
101
  # @example Calculating the complexity of a list field
102
102
  # field :items, types[ItemType] do
103
103
  # argument :limit, !types.Int
104
104
  # # Mulitply the child complexity by the possible items on the list
105
- # complexity -> (ctx, args, child_complexity) { child_complexity * args[:limit] }
105
+ # complexity ->(ctx, args, child_complexity) { child_complexity * args[:limit] }
106
106
  # end
107
107
  #
108
108
  # @example Creating a field, then assigning it to a type
@@ -110,7 +110,7 @@ module GraphQL
110
110
  # name("Name")
111
111
  # type(!types.String)
112
112
  # description("The name of this thing")
113
- # resolve -> (object, arguments, context) { object.name }
113
+ # resolve ->(object, arguments, context) { object.name }
114
114
  # end
115
115
  #
116
116
  # NamedType = GraphQL::ObjectType.define do
@@ -142,7 +142,7 @@ module GraphQL
142
142
  # @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
143
143
 
144
144
  # @!attribute complexity
145
- # @return [Numeric, Proc] The complexity for this field (default: 1), as a constant or a proc like `-> (query_ctx, args, child_complexity) { } # Numeric`
145
+ # @return [Numeric, Proc] The complexity for this field (default: 1), as a constant or a proc like `->(query_ctx, args, child_complexity) { } # Numeric`
146
146
 
147
147
  def initialize
148
148
  @complexity = 1
@@ -2,6 +2,6 @@ GraphQL::FLOAT_TYPE = GraphQL::ScalarType.define do
2
2
  name "Float"
3
3
  description "Represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point)."
4
4
 
5
- coerce_input -> (value) { value.is_a?(Numeric) ? value.to_f : nil }
6
- coerce_result -> (value) { value.to_f }
5
+ coerce_input ->(value) { value.is_a?(Numeric) ? value.to_f : nil }
6
+ coerce_result ->(value) { value.to_f }
7
7
  end
@@ -2,8 +2,8 @@ GraphQL::ID_TYPE = GraphQL::ScalarType.define do
2
2
  name "ID"
3
3
  description "Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"VXNlci0xMA==\"`) or integer (such as `4`) input value will be accepted as an ID."
4
4
 
5
- coerce_result -> (value) { value.to_s }
6
- coerce_input -> (value) {
5
+ coerce_result ->(value) { value.to_s }
6
+ coerce_input ->(value) {
7
7
  case value
8
8
  when String, Fixnum, Bignum
9
9
  value.to_s
@@ -15,7 +15,7 @@ module GraphQL
15
15
  # In a `resolve` function, you can access the values by making nested lookups on `args`.
16
16
  #
17
17
  # @example Accessing input values in a resolve function
18
- # resolve -> (obj, args, ctx) {
18
+ # resolve ->(obj, args, ctx) {
19
19
  # args[:player][:name] # => "Tony Gwynn"
20
20
  # args[:player][:number] # => 19
21
21
  # args[:player].to_h # { "name" => "Tony Gwynn", "number" => 19 }
@@ -2,6 +2,6 @@ GraphQL::INT_TYPE = GraphQL::ScalarType.define do
2
2
  name "Int"
3
3
  description "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1."
4
4
 
5
- coerce_input -> (value) { value.is_a?(Numeric) ? value.to_i : nil }
6
- coerce_result -> (value) { value.to_i }
5
+ coerce_input ->(value) { value.is_a?(Numeric) ? value.to_i : nil }
6
+ coerce_result ->(value) { value.to_i }
7
7
  end
@@ -31,7 +31,7 @@ module GraphQL
31
31
  def validate(context)
32
32
  visitor = context.visitor
33
33
 
34
- visitor[Nodes::OperationDefinition].enter << -> (ast_node, prev_ast_node) {
34
+ visitor[Nodes::OperationDefinition].enter << ->(ast_node, prev_ast_node) {
35
35
  node = Node.new(
36
36
  return_type: context.type_definition && context.type_definition.unwrap,
37
37
  ast_node: ast_node,
@@ -42,7 +42,7 @@ module GraphQL
42
42
  @operations[ast_node.name] = node
43
43
  }
44
44
 
45
- visitor[Nodes::Field].enter << -> (ast_node, prev_ast_node) {
45
+ visitor[Nodes::Field].enter << ->(ast_node, prev_ast_node) {
46
46
  parent_node = @nodes.last
47
47
  node_name = ast_node.alias || ast_node.name
48
48
  # This node might not be novel, eg inside an inline fragment
@@ -64,11 +64,11 @@ module GraphQL
64
64
  @parent_directives.push([])
65
65
  }
66
66
 
67
- visitor[Nodes::InlineFragment].enter << -> (ast_node, prev_ast_node) {
67
+ visitor[Nodes::InlineFragment].enter << ->(ast_node, prev_ast_node) {
68
68
  @parent_directives.push(InlineFragmentDirectives.new)
69
69
  }
70
70
 
71
- visitor[Nodes::Directive].enter << -> (ast_node, prev_ast_node) {
71
+ visitor[Nodes::Directive].enter << ->(ast_node, prev_ast_node) {
72
72
  # It could be a query error where a directive is somewhere it shouldn't be
73
73
  if @parent_directives.any?
74
74
  directive_irep_node = Node.new(
@@ -83,7 +83,7 @@ module GraphQL
83
83
  end
84
84
  }
85
85
 
86
- visitor[Nodes::FragmentSpread].enter << -> (ast_node, prev_ast_node) {
86
+ visitor[Nodes::FragmentSpread].enter << ->(ast_node, prev_ast_node) {
87
87
  parent_node = @nodes.last
88
88
  # Record _both sides_ of the dependency
89
89
  spread_node = Node.new(
@@ -100,7 +100,7 @@ module GraphQL
100
100
  @parent_directives.push([])
101
101
  }
102
102
 
103
- visitor[Nodes::FragmentDefinition].enter << -> (ast_node, prev_ast_node) {
103
+ visitor[Nodes::FragmentDefinition].enter << ->(ast_node, prev_ast_node) {
104
104
  node = Node.new(
105
105
  parent: nil,
106
106
  name: ast_node.name,
@@ -111,11 +111,11 @@ module GraphQL
111
111
  @fragments[ast_node.name] = node
112
112
  }
113
113
 
114
- visitor[Nodes::InlineFragment].leave << -> (ast_node, prev_ast_node) {
114
+ visitor[Nodes::InlineFragment].leave << ->(ast_node, prev_ast_node) {
115
115
  @parent_directives.pop
116
116
  }
117
117
 
118
- visitor[Nodes::FragmentSpread].leave << -> (ast_node, prev_ast_node) {
118
+ visitor[Nodes::FragmentSpread].leave << ->(ast_node, prev_ast_node) {
119
119
  # Capture any directives that apply to this spread
120
120
  # so that they can be applied to fields when
121
121
  # the fragment is merged in later
@@ -125,7 +125,7 @@ module GraphQL
125
125
  spread_node.directives.merge(applicable_directives)
126
126
  }
127
127
 
128
- visitor[Nodes::FragmentDefinition].leave << -> (ast_node, prev_ast_node) {
128
+ visitor[Nodes::FragmentDefinition].leave << ->(ast_node, prev_ast_node) {
129
129
  # This fragment doesn't depend on any others,
130
130
  # we should save it as the starting point for dependency resolution
131
131
  frag_node = @nodes.pop
@@ -134,11 +134,11 @@ module GraphQL
134
134
  end
135
135
  }
136
136
 
137
- visitor[Nodes::OperationDefinition].leave << -> (ast_node, prev_ast_node) {
137
+ visitor[Nodes::OperationDefinition].leave << ->(ast_node, prev_ast_node) {
138
138
  @nodes.pop
139
139
  }
140
140
 
141
- visitor[Nodes::Field].leave << -> (ast_node, prev_ast_node) {
141
+ visitor[Nodes::Field].leave << ->(ast_node, prev_ast_node) {
142
142
  # Pop this field's node
143
143
  # and record any directives that were visited
144
144
  # during this field & before it (eg, inline fragments)
@@ -148,7 +148,7 @@ module GraphQL
148
148
  field_node.included ||= GraphQL::Execution::DirectiveChecks.include?(applicable_directives, context.query)
149
149
  }
150
150
 
151
- visitor[Nodes::Document].leave << -> (ast_node, prev_ast_node) {
151
+ visitor[Nodes::Document].leave << ->(ast_node, prev_ast_node) {
152
152
  # Resolve fragment dependencies. Start with fragments with no
153
153
  # dependencies and work along the spreads.
154
154
  while fragment_node = @independent_fragments.pop
@@ -1,4 +1,4 @@
1
1
  GraphQL::Introspection::ArgumentsField = GraphQL::Field.define do
2
2
  type !GraphQL::ListType.new(of_type: !GraphQL::Introspection::InputValueType)
3
- resolve -> (target, a, c) { target.arguments.values }
3
+ resolve ->(target, a, c) { target.arguments.values }
4
4
  end
@@ -6,7 +6,7 @@ GraphQL::Introspection::EnumValueType = GraphQL::ObjectType.define do
6
6
  field :name, !types.String
7
7
  field :description, types.String
8
8
  field :isDeprecated, !types.Boolean do
9
- resolve -> (obj, a, c) { !!obj.deprecation_reason }
9
+ resolve ->(obj, a, c) { !!obj.deprecation_reason }
10
10
  end
11
11
  field :deprecationReason, types.String, property: :deprecation_reason
12
12
  end
@@ -1,7 +1,7 @@
1
1
  GraphQL::Introspection::EnumValuesField = GraphQL::Field.define do
2
2
  type types[!GraphQL::Introspection::EnumValueType]
3
3
  argument :includeDeprecated, types.Boolean, default_value: false
4
- resolve -> (object, arguments, context) do
4
+ resolve ->(object, arguments, context) do
5
5
  return nil if !object.kind.enum?
6
6
  fields = object.values.values
7
7
  if !arguments["includeDeprecated"]
@@ -7,7 +7,7 @@ GraphQL::Introspection::FieldType = GraphQL::ObjectType.define do
7
7
  field :args, GraphQL::Introspection::ArgumentsField
8
8
  field :type, !GraphQL::Introspection::TypeType
9
9
  field :isDeprecated, !types.Boolean do
10
- resolve -> (obj, a, c) { !!obj.deprecation_reason }
10
+ resolve ->(obj, a, c) { !!obj.deprecation_reason }
11
11
  end
12
12
  field :deprecationReason, types.String, property: :deprecation_reason
13
13
  end
@@ -1,7 +1,7 @@
1
1
  GraphQL::Introspection::FieldsField = GraphQL::Field.define do
2
2
  type -> { types[!GraphQL::Introspection::FieldType] }
3
3
  argument :includeDeprecated, GraphQL::BOOLEAN_TYPE, default_value: false
4
- resolve -> (object, arguments, context) {
4
+ resolve ->(object, arguments, context) {
5
5
  return nil if !object.kind.fields?
6
6
  fields = object.all_fields
7
7
  if !arguments["includeDeprecated"]
@@ -1,7 +1,7 @@
1
1
  GraphQL::Introspection::InputFieldsField = GraphQL::Field.define do
2
2
  name "inputFields"
3
3
  type types[!GraphQL::Introspection::InputValueType]
4
- resolve -> (target, a, c) {
4
+ resolve ->(target, a, c) {
5
5
  if target.kind.input_object?
6
6
  target.input_fields.values
7
7
  else
@@ -7,9 +7,9 @@ GraphQL::Introspection::InputValueType = GraphQL::ObjectType.define do
7
7
  field :description, types.String
8
8
  field :type, !GraphQL::Introspection::TypeType
9
9
  field :defaultValue, types.String, "A GraphQL-formatted string representing the default value for this input value." do
10
- resolve -> (obj, args, ctx) {
10
+ resolve ->(obj, args, ctx) {
11
11
  value = obj.default_value
12
- value.nil? ? nil : JSON.dump(obj.type.coerce_result(value))
12
+ value.nil? ? nil : JSON.generate(obj.type.coerce_result(value), quirks_mode: true)
13
13
  }
14
14
  end
15
15
  end
@@ -1,4 +1,4 @@
1
1
  GraphQL::Introspection::InterfacesField = GraphQL::Field.define do
2
2
  type -> { types[!GraphQL::Introspection::TypeType] }
3
- resolve -> (target, a, c) { target.kind.object? ? target.interfaces : nil }
3
+ resolve ->(target, a, c) { target.kind.object? ? target.interfaces : nil }
4
4
  end
@@ -1,5 +1,5 @@
1
1
  GraphQL::Introspection::OfTypeField = GraphQL::Field.define do
2
2
  name "ofType"
3
3
  type -> { GraphQL::Introspection::TypeType }
4
- resolve -> (obj, args, ctx) { obj.kind.wraps? ? obj.of_type : nil }
4
+ resolve ->(obj, args, ctx) { obj.kind.wraps? ? obj.of_type : nil }
5
5
  end
@@ -1,6 +1,6 @@
1
1
  GraphQL::Introspection::PossibleTypesField = GraphQL::Field.define do
2
2
  type -> { types[!GraphQL::Introspection::TypeType] }
3
- resolve -> (target, args, ctx) {
3
+ resolve ->(target, args, ctx) {
4
4
  if target.kind.resolves?
5
5
  ctx.schema.possible_types(target)
6
6
  else
@@ -7,7 +7,7 @@ module GraphQL
7
7
  name("__schema")
8
8
  description("This GraphQL schema")
9
9
  type(!GraphQL::Introspection::SchemaType)
10
- resolve -> (o, a, c) { wrapped_type }
10
+ resolve ->(o, a, c) { wrapped_type }
11
11
  end
12
12
  end
13
13
  end
@@ -5,22 +5,22 @@ GraphQL::Introspection::SchemaType = GraphQL::ObjectType.define do
5
5
  "query, mutation, and subscription operations."
6
6
 
7
7
  field :types, !types[!GraphQL::Introspection::TypeType], "A list of all types supported by this server." do
8
- resolve -> (obj, arg, ctx) { obj.types.values }
8
+ resolve ->(obj, arg, ctx) { obj.types.values }
9
9
  end
10
10
 
11
11
  field :queryType, !GraphQL::Introspection::TypeType, "The type that query operations will be rooted at." do
12
- resolve -> (obj, arg, ctx) { obj.query }
12
+ resolve ->(obj, arg, ctx) { obj.query }
13
13
  end
14
14
 
15
15
  field :mutationType, GraphQL::Introspection::TypeType, "If this server supports mutation, the type that mutation operations will be rooted at." do
16
- resolve -> (obj, arg, ctx) { obj.mutation }
16
+ resolve ->(obj, arg, ctx) { obj.mutation }
17
17
  end
18
18
 
19
19
  field :subscriptionType, GraphQL::Introspection::TypeType, "If this server support subscription, the type that subscription operations will be rooted at." do
20
- resolve -> (obj, arg, ctx) { obj.subscription }
20
+ resolve ->(obj, arg, ctx) { obj.subscription }
21
21
  end
22
22
 
23
23
  field :directives, !types[!GraphQL::Introspection::DirectiveType], "A list of all directives supported by this server." do
24
- resolve -> (obj, arg, ctx) { obj.directives.values }
24
+ resolve ->(obj, arg, ctx) { obj.directives.values }
25
25
  end
26
26
  end
@@ -8,7 +8,7 @@ module GraphQL
8
8
  description("A type in the GraphQL system")
9
9
  type(GraphQL::Introspection::TypeType)
10
10
  argument :name, !types.String
11
- resolve -> (o, args, c) { type_hash.fetch(args["name"], nil) }
11
+ resolve ->(o, args, c) { type_hash.fetch(args["name"], nil) }
12
12
  end
13
13
  end
14
14
  end
@@ -8,16 +8,16 @@ GraphQL::Introspection::TypeType = GraphQL::ObjectType.define do
8
8
  "they describe. Abstract types, Union and Interface, provide the Object types "\
9
9
  "possible at runtime. List and NonNull types compose other types."
10
10
 
11
- field :name, types.String
12
- field :description, types.String
13
11
  field :kind do
14
12
  type !GraphQL::Introspection::TypeKindEnum
15
- resolve -> (target, a, c) { target.kind.name }
13
+ resolve ->(target, a, c) { target.kind.name }
16
14
  end
15
+ field :name, types.String
16
+ field :description, types.String
17
17
  field :fields, field: GraphQL::Introspection::FieldsField
18
- field :ofType, field: GraphQL::Introspection::OfTypeField
19
- field :inputFields, field: GraphQL::Introspection::InputFieldsField
18
+ field :interfaces, field: GraphQL::Introspection::InterfacesField
20
19
  field :possibleTypes, field: GraphQL::Introspection::PossibleTypesField
21
20
  field :enumValues, field: GraphQL::Introspection::EnumValuesField
22
- field :interfaces, field: GraphQL::Introspection::InterfacesField
21
+ field :inputFields, field: GraphQL::Introspection::InputFieldsField
22
+ field :ofType, field: GraphQL::Introspection::OfTypeField
23
23
  end