graphql 2.3.9 → 2.3.10

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: aa940f82a3f79bd899de908905d6656c5a4b60b6174f70380ed42d3643992085
4
- data.tar.gz: 3c20f6255693b62acc10cb4d9069c6433d7548a31f9ae2a8c4554f6d91646dc9
3
+ metadata.gz: df4f4d50869f6ef14685ae04e9020a6b1c151d9fd287af7d86d139aadfc2f105
4
+ data.tar.gz: 0415f6e0012b4a9517e84d5de66ebccbff41ce01b384b49c480cda7b5353d16d
5
5
  SHA512:
6
- metadata.gz: e92413d9e9a3e5fc507ef4522167aa2268f6c5645847f6c5f7b97bfad1a94cd043048d2a7a7cf7c3df6ff748e76266a63101c96c25bf0fd3601a1bd8f5e07311
7
- data.tar.gz: 58ca270e89fa01dd0bac02cfd559250b2088979bd6a7a57c2c722196d1bf7e824c35f29b3d1e98ffe390157d2bebcedbc3e33cddec21cb55e0abe4644d3275dc
6
+ metadata.gz: 7921e2420473405956845345b75ba8c4768e9d90cf6d96b0249844524e7c53ff00ec11ed940635a3f12c264cb52095310be4e6a642c4806362ce2e9f5fe7d15f
7
+ data.tar.gz: 3e33cd66559ec943b8b5e74124343918037176d1727d4ed425ccee384c3505708c848b5dac0dc04d2c68858ae9bc8717b204fe66dfee48adc981bf4a41fa284c
@@ -186,8 +186,11 @@ This key should have been loaded already. This is a bug in GraphQL::Dataloader,
186
186
  ERR
187
187
  end
188
188
  result = @results[key]
189
-
190
- raise result if result.class <= StandardError
189
+ if result.is_a?(StandardError)
190
+ # Dup it because the rescuer may modify it.
191
+ # (This happens for GraphQL::ExecutionErrors, at least)
192
+ raise result.dup
193
+ end
191
194
 
192
195
  result
193
196
  end
@@ -141,7 +141,12 @@ module GraphQL
141
141
  parse_operation_type
142
142
  end
143
143
 
144
- op_name = at?(:IDENTIFIER) ? parse_name : nil
144
+ op_name = case token_name
145
+ when :LPAREN, :LCURLY, :DIR_SIGN
146
+ nil
147
+ else
148
+ parse_name
149
+ end
145
150
 
146
151
  variable_definitions = if at?(:LPAREN)
147
152
  expect_token(:LPAREN)
@@ -398,6 +403,9 @@ module GraphQL
398
403
  def parse_union_members
399
404
  if at?(:EQUALS)
400
405
  expect_token :EQUALS
406
+ if at?(:PIPE)
407
+ advance_token
408
+ end
401
409
  list = [parse_type_name]
402
410
  while at?(:PIPE)
403
411
  advance_token
@@ -166,7 +166,11 @@ module GraphQL
166
166
  end
167
167
 
168
168
  def inherited(child_class)
169
- child_class.const_set(:UnresolvedValueError, Class.new(Schema::Enum::UnresolvedValueError))
169
+ if child_class.name
170
+ # Don't assign a custom error class to anonymous classes
171
+ # because they would end up with names like `#<Class0x1234>::UnresolvedValueError` which messes up bug trackers
172
+ child_class.const_set(:UnresolvedValueError, Class.new(Schema::Enum::UnresolvedValueError))
173
+ end
170
174
  super
171
175
  end
172
176
 
@@ -7,7 +7,11 @@ module GraphQL
7
7
  module HasUnresolvedTypeError
8
8
  private
9
9
  def add_unresolved_type_error(child_class)
10
- child_class.const_set(:UnresolvedTypeError, Class.new(GraphQL::UnresolvedTypeError))
10
+ if child_class.name # Don't set this for anonymous classes
11
+ child_class.const_set(:UnresolvedTypeError, Class.new(GraphQL::UnresolvedTypeError))
12
+ else
13
+ child_class.const_set(:UnresolvedTypeError, UnresolvedTypeError)
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -5,36 +5,27 @@ module GraphQL
5
5
  def on_variable_definition(node, parent)
6
6
  if !node.default_value.nil?
7
7
  value = node.default_value
8
- if node.type.is_a?(GraphQL::Language::Nodes::NonNullType)
9
- add_error(GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTypedError.new(
10
- "Non-null variable $#{node.name} can't have a default value",
11
- nodes: node,
12
- name: node.name,
13
- error_type: VariableDefaultValuesAreCorrectlyTypedError::VIOLATIONS[:INVALID_ON_NON_NULL]
14
- ))
8
+ type = context.schema.type_from_ast(node.type, context: context)
9
+ if type.nil?
10
+ # This is handled by another validator
15
11
  else
16
- type = context.schema.type_from_ast(node.type, context: context)
17
- if type.nil?
18
- # This is handled by another validator
19
- else
20
- validation_result = context.validate_literal(value, type)
12
+ validation_result = context.validate_literal(value, type)
21
13
 
22
- if !validation_result.valid?
23
- problems = validation_result.problems
24
- first_problem = problems && problems.first
25
- if first_problem
26
- error_message = first_problem["explanation"]
27
- end
28
-
29
- error_message ||= "Default value for $#{node.name} doesn't match type #{type.to_type_signature}"
30
- add_error(GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTypedError.new(
31
- error_message,
32
- nodes: node,
33
- name: node.name,
34
- type: type.to_type_signature,
35
- error_type: VariableDefaultValuesAreCorrectlyTypedError::VIOLATIONS[:INVALID_TYPE],
36
- ))
14
+ if !validation_result.valid?
15
+ problems = validation_result.problems
16
+ first_problem = problems && problems.first
17
+ if first_problem
18
+ error_message = first_problem["explanation"]
37
19
  end
20
+
21
+ error_message ||= "Default value for $#{node.name} doesn't match type #{type.to_type_signature}"
22
+ add_error(GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTypedError.new(
23
+ error_message,
24
+ nodes: node,
25
+ name: node.name,
26
+ type: type.to_type_signature,
27
+ error_type: VariableDefaultValuesAreCorrectlyTypedError::VIOLATIONS[:INVALID_TYPE],
28
+ ))
38
29
  end
39
30
  end
40
31
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.3.9"
3
+ VERSION = "2.3.10"
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: 2.3.9
4
+ version: 2.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64