graphql-client 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/client/collocated_enforcement.rb +1 -1
- data/lib/graphql/client/response.rb +1 -0
- data/lib/graphql/client/schema/enum_type.rb +17 -2
- data/lib/graphql/client/schema/object_type.rb +4 -3
- data/lib/graphql/client/schema.rb +3 -2
- data/lib/graphql/client.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 701013be051b65eb45137df51b2cff9ea320252872d39229179f4fc25530ed44
|
4
|
+
data.tar.gz: 72c632eae9478ceb269955e50a6f0636c54672713905f55cea7b965997fdadb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b863aa17a14fb51f2957cc4a0bb30a741ed55babdbce7f32aa76bd4db9a0fdb3764f11c1402b23bdd94c7a547ce7dc37bfad778c4b0c31edf0c5ea0f16b7111a
|
7
|
+
data.tar.gz: d629b3047219db9bc9805bd39a59ea7f4540540905b9cda2d9d84aaddfd8044b2517bc25c4a3af6c7c9a9dc2eddb2daff3baeed5eb9a8342c7278c6e272999fb
|
@@ -26,7 +26,7 @@ module GraphQL
|
|
26
26
|
return yield if Thread.current[:query_result_caller_location_ignore]
|
27
27
|
|
28
28
|
if (location.path != path) && !(WHITELISTED_GEM_NAMES.any? { |g| location.path.include?("gems/#{g}") })
|
29
|
-
error = NonCollocatedCallerError.new("#{method} was called outside of '#{path}' https://
|
29
|
+
error = NonCollocatedCallerError.new("#{method} was called outside of '#{path}' https://github.com/github-community-projects/graphql-client/blob/master/guides/collocated-call-sites.md")
|
30
30
|
error.set_backtrace(caller(2))
|
31
31
|
raise error
|
32
32
|
end
|
@@ -16,6 +16,10 @@ module GraphQL
|
|
16
16
|
@enum = enum
|
17
17
|
end
|
18
18
|
|
19
|
+
def unknown_enum_value?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
19
23
|
def respond_to_missing?(method_name, include_private = false)
|
20
24
|
if method_name[-1] == "?" && @enum.include?(method_name[0..-2])
|
21
25
|
true
|
@@ -37,6 +41,12 @@ module GraphQL
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
44
|
+
class UnexpectedEnumValue < String
|
45
|
+
def unknown_enum_value?
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
40
50
|
# Internal: Construct enum wrapper from another GraphQL::EnumType.
|
41
51
|
#
|
42
52
|
# type - GraphQL::EnumType instance
|
@@ -78,8 +88,13 @@ module GraphQL
|
|
78
88
|
def cast(value, _errors = nil)
|
79
89
|
case value
|
80
90
|
when String
|
81
|
-
|
82
|
-
|
91
|
+
if @values.key?(value)
|
92
|
+
@values[value]
|
93
|
+
elsif schema_module.raise_on_unknown_enum_value
|
94
|
+
raise Error, "unexpected enum value #{value}"
|
95
|
+
else
|
96
|
+
UnexpectedEnumValue.new(value).freeze
|
97
|
+
end
|
83
98
|
when NilClass
|
84
99
|
value
|
85
100
|
else
|
@@ -192,6 +192,7 @@ module GraphQL
|
|
192
192
|
def to_h
|
193
193
|
@data
|
194
194
|
end
|
195
|
+
alias :to_hash :to_h
|
195
196
|
|
196
197
|
def _definer
|
197
198
|
@definer
|
@@ -255,13 +256,13 @@ module GraphQL
|
|
255
256
|
end
|
256
257
|
|
257
258
|
unless field
|
258
|
-
raise UnimplementedFieldError, "undefined field `#{e.name}' on #{type.graphql_name} type. https://
|
259
|
+
raise UnimplementedFieldError, "undefined field `#{e.name}' on #{type.graphql_name} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/unimplemented-field-error.md"
|
259
260
|
end
|
260
261
|
|
261
262
|
if @data.key?(field.name)
|
262
|
-
raise ImplicitlyFetchedFieldError, "implicitly fetched field `#{field.name}' on #{type} type. https://
|
263
|
+
raise ImplicitlyFetchedFieldError, "implicitly fetched field `#{field.name}' on #{type} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/implicitly-fetched-field-error.md"
|
263
264
|
else
|
264
|
-
raise UnfetchedFieldError, "unfetched field `#{field.name}' on #{type} type. https://
|
265
|
+
raise UnfetchedFieldError, "unfetched field `#{field.name}' on #{type} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/unfetched-field-error.md"
|
265
266
|
end
|
266
267
|
end
|
267
268
|
end
|
@@ -43,7 +43,7 @@ module GraphQL
|
|
43
43
|
def set_class(type_name, klass)
|
44
44
|
class_name = normalize_type_name(type_name)
|
45
45
|
|
46
|
-
if
|
46
|
+
if const_defined?(class_name, false)
|
47
47
|
raise ArgumentError,
|
48
48
|
"Can't define #{class_name} to represent type #{type_name} " \
|
49
49
|
"because it's already defined"
|
@@ -66,9 +66,10 @@ module GraphQL
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def self.generate(schema)
|
69
|
+
def self.generate(schema, raise_on_unknown_enum_value: true)
|
70
70
|
mod = Module.new
|
71
71
|
mod.extend ClassMethods
|
72
|
+
mod.define_singleton_method(:raise_on_unknown_enum_value) { raise_on_unknown_enum_value }
|
72
73
|
|
73
74
|
cache = {}
|
74
75
|
schema.types.each do |name, type|
|
data/lib/graphql/client.rb
CHANGED
@@ -91,7 +91,7 @@ module GraphQL
|
|
91
91
|
result
|
92
92
|
end
|
93
93
|
|
94
|
-
def initialize(schema:, execute: nil, enforce_collocated_callers: false)
|
94
|
+
def initialize(schema:, execute: nil, enforce_collocated_callers: false, raise_on_unknown_enum_value: true)
|
95
95
|
@schema = self.class.load_schema(schema)
|
96
96
|
@execute = execute
|
97
97
|
@document = GraphQL::Language::Nodes::Document.new(definitions: [])
|
@@ -101,7 +101,7 @@ module GraphQL
|
|
101
101
|
if schema.is_a?(Class)
|
102
102
|
@possible_types = schema.possible_types
|
103
103
|
end
|
104
|
-
@types = Schema.generate(@schema)
|
104
|
+
@types = Schema.generate(@schema, raise_on_unknown_enum_value: raise_on_unknown_enum_value)
|
105
105
|
end
|
106
106
|
|
107
107
|
# A cache of the schema's merged possible types
|
@@ -338,7 +338,7 @@ module GraphQL
|
|
338
338
|
end
|
339
339
|
|
340
340
|
if allow_dynamic_queries == false && definition.name.nil?
|
341
|
-
raise DynamicQueryError, "expected definition to be assigned to a static constant https://
|
341
|
+
raise DynamicQueryError, "expected definition to be assigned to a static constant https://github.com/github-community-projects/graphql-client/blob/master/guides/dynamic-query-error.md"
|
342
342
|
end
|
343
343
|
|
344
344
|
variables = deep_stringify_keys(variables)
|
@@ -403,7 +403,6 @@ module GraphQL
|
|
403
403
|
|
404
404
|
doc.definitions.map do |node|
|
405
405
|
deps = Set.new
|
406
|
-
definitions = document_dependencies.definitions.map { |x| [x.name, x] }.to_h
|
407
406
|
|
408
407
|
queue = [node.name]
|
409
408
|
while name = queue.shift
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|