graphql 1.11.4 → 1.11.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/object_generator.rb +2 -0
- data/lib/generators/graphql/templates/union.erb +1 -1
- data/lib/graphql.rb +17 -0
- data/lib/graphql/argument.rb +3 -3
- data/lib/graphql/backtrace/tracer.rb +2 -1
- data/lib/graphql/define/assign_global_id_field.rb +2 -2
- data/lib/graphql/execution/interpreter.rb +10 -0
- data/lib/graphql/execution/interpreter/arguments.rb +21 -6
- data/lib/graphql/execution/interpreter/arguments_cache.rb +8 -0
- data/lib/graphql/execution/interpreter/runtime.rb +70 -42
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/introspection.rb +96 -0
- data/lib/graphql/introspection/field_type.rb +7 -3
- data/lib/graphql/introspection/input_value_type.rb +6 -0
- data/lib/graphql/introspection/introspection_query.rb +6 -92
- data/lib/graphql/introspection/type_type.rb +7 -3
- data/lib/graphql/invalid_null_error.rb +1 -1
- data/lib/graphql/language/block_string.rb +24 -5
- data/lib/graphql/language/lexer.rb +7 -3
- data/lib/graphql/language/lexer.rl +7 -3
- data/lib/graphql/language/nodes.rb +1 -1
- data/lib/graphql/language/parser.rb +107 -103
- data/lib/graphql/language/parser.y +4 -0
- data/lib/graphql/language/sanitized_printer.rb +59 -26
- data/lib/graphql/name_validator.rb +6 -7
- data/lib/graphql/pagination/connections.rb +11 -3
- data/lib/graphql/query.rb +6 -3
- data/lib/graphql/query/context.rb +14 -3
- data/lib/graphql/query/validation_pipeline.rb +1 -1
- data/lib/graphql/relay/array_connection.rb +2 -2
- data/lib/graphql/relay/range_add.rb +14 -5
- data/lib/graphql/schema.rb +47 -19
- data/lib/graphql/schema/argument.rb +56 -5
- data/lib/graphql/schema/build_from_definition.rb +67 -38
- data/lib/graphql/schema/default_type_error.rb +2 -0
- data/lib/graphql/schema/directive/deprecated.rb +1 -1
- data/lib/graphql/schema/field.rb +32 -16
- data/lib/graphql/schema/field/connection_extension.rb +8 -7
- data/lib/graphql/schema/field/scope_extension.rb +1 -1
- data/lib/graphql/schema/input_object.rb +5 -3
- data/lib/graphql/schema/interface.rb +1 -1
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/loader.rb +1 -0
- data/lib/graphql/schema/member/build_type.rb +14 -4
- data/lib/graphql/schema/member/has_arguments.rb +54 -53
- data/lib/graphql/schema/member/has_fields.rb +2 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +2 -2
- data/lib/graphql/schema/relay_classic_mutation.rb +4 -2
- data/lib/graphql/schema/timeout.rb +29 -15
- data/lib/graphql/schema/unique_within_type.rb +1 -2
- data/lib/graphql/schema/validation.rb +8 -0
- data/lib/graphql/static_validation.rb +1 -0
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +25 -17
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +29 -7
- data/lib/graphql/subscriptions.rb +1 -3
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +21 -7
- data/lib/graphql/tracing/platform_tracing.rb +1 -1
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +4 -1
- data/lib/graphql/types/int.rb +9 -2
- data/lib/graphql/types/relay/base_connection.rb +2 -1
- data/lib/graphql/types/relay/base_edge.rb +2 -1
- data/lib/graphql/types/string.rb +7 -1
- data/lib/graphql/unauthorized_error.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b72615f5488c1aa58c921128dd067d9f098b4617c954ac267e37efa72a9107c
|
4
|
+
data.tar.gz: 4690738202ecd5d048802c80f1fc87095e0c1de4a02adcba26e88415f401908c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 744ca52fc03919a071013a27139112c2c18e487f333ee335ea374feaef06bb904079d4c54e0ddf088d2b5dfa345172efb3063faefa792c1c8ade38616752fa1a
|
7
|
+
data.tar.gz: 90fffd6928d128f2516e4f49c9d729a26a57101683e19d0a90818c45f431bae221e4b8b1bf8d7bc374e20c8e98e3f0a0963877e818ae946f999d40942182cddd
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% module_namespacing_when_supported do -%>
|
2
2
|
module Types
|
3
3
|
class <%= type_ruby_name.split('::')[-1] %> < Types::BaseUnion
|
4
|
-
<% if possible_types.any? %> possible_types
|
4
|
+
<% if possible_types.any? %> possible_types <%= normalized_possible_types.join(", ") %>
|
5
5
|
<% end %> end
|
6
6
|
end
|
7
7
|
<% end -%>
|
data/lib/graphql.rb
CHANGED
@@ -21,6 +21,14 @@ module GraphQL
|
|
21
21
|
class RequiredImplementationMissingError < Error
|
22
22
|
end
|
23
23
|
|
24
|
+
class << self
|
25
|
+
def default_parser
|
26
|
+
@default_parser ||= GraphQL::Language::Parser
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_writer :default_parser
|
30
|
+
end
|
31
|
+
|
24
32
|
# Turn a query string or schema definition into an AST
|
25
33
|
# @param graphql_string [String] a GraphQL query string or schema definition
|
26
34
|
# @return [GraphQL::Language::Nodes::Document]
|
@@ -61,6 +69,14 @@ module GraphQL
|
|
61
69
|
end
|
62
70
|
end
|
63
71
|
end
|
72
|
+
|
73
|
+
module StringMatchBackport
|
74
|
+
refine String do
|
75
|
+
def match?(pattern)
|
76
|
+
self =~ pattern
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
64
80
|
end
|
65
81
|
|
66
82
|
# Order matters for these:
|
@@ -113,6 +129,7 @@ require "graphql/introspection"
|
|
113
129
|
require "graphql/analysis_error"
|
114
130
|
require "graphql/coercion_error"
|
115
131
|
require "graphql/invalid_name_error"
|
132
|
+
require "graphql/integer_decoding_error"
|
116
133
|
require "graphql/integer_encoding_error"
|
117
134
|
require "graphql/string_encoding_error"
|
118
135
|
require "graphql/internal_representation"
|
data/lib/graphql/argument.rb
CHANGED
@@ -3,14 +3,14 @@ module GraphQL
|
|
3
3
|
# @api deprecated
|
4
4
|
class Argument
|
5
5
|
include GraphQL::Define::InstanceDefinable
|
6
|
-
accepts_definitions :name, :type, :description, :default_value, :as, :prepare, :method_access
|
6
|
+
accepts_definitions :name, :type, :description, :default_value, :as, :prepare, :method_access, :deprecation_reason
|
7
7
|
attr_reader :default_value
|
8
|
-
attr_accessor :description, :name, :as
|
8
|
+
attr_accessor :description, :name, :as, :deprecation_reason
|
9
9
|
attr_accessor :ast_node
|
10
10
|
attr_accessor :method_access
|
11
11
|
alias :graphql_name :name
|
12
12
|
|
13
|
-
ensure_defined(:name, :description, :default_value, :type=, :type, :as, :expose_as, :prepare, :method_access)
|
13
|
+
ensure_defined(:name, :description, :default_value, :type=, :type, :as, :expose_as, :prepare, :method_access, :deprecation_reason)
|
14
14
|
|
15
15
|
# @api private
|
16
16
|
module DefaultPrepare
|
@@ -15,7 +15,8 @@ module GraphQL
|
|
15
15
|
when "validate", "analyze_query", "execute_query", "execute_query_lazy"
|
16
16
|
metadata[:query] || metadata[:queries]
|
17
17
|
when "execute_field", "execute_field_lazy"
|
18
|
-
|
18
|
+
# The interpreter passes `query:`, legacy passes `context:`
|
19
|
+
metadata[:context] || ((q = metadata[:query]) && q.context)
|
19
20
|
else
|
20
21
|
# Custom key, no backtrace data for this
|
21
22
|
nil
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Define
|
4
4
|
module AssignGlobalIdField
|
5
|
-
def self.call(type_defn, field_name)
|
5
|
+
def self.call(type_defn, field_name, **field_kwargs)
|
6
6
|
resolve = GraphQL::Relay::GlobalIdResolve.new(type: type_defn)
|
7
|
-
GraphQL::Define::AssignObjectField.call(type_defn, field_name, type: GraphQL::ID_TYPE.to_non_null_type, resolve: resolve)
|
7
|
+
GraphQL::Define::AssignObjectField.call(type_defn, field_name, **field_kwargs, type: GraphQL::ID_TYPE.to_non_null_type, resolve: resolve)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -93,6 +93,16 @@ module GraphQL
|
|
93
93
|
tracer.trace("execute_query_lazy", {multiplex: multiplex, query: query}) do
|
94
94
|
Interpreter::Resolve.resolve_all(final_values)
|
95
95
|
end
|
96
|
+
queries.each do |query|
|
97
|
+
runtime = query.context.namespace(:interpreter)[:runtime]
|
98
|
+
if runtime
|
99
|
+
runtime.delete_interpreter_context(:current_path)
|
100
|
+
runtime.delete_interpreter_context(:current_field)
|
101
|
+
runtime.delete_interpreter_context(:current_object)
|
102
|
+
runtime.delete_interpreter_context(:current_arguments)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
nil
|
96
106
|
end
|
97
107
|
|
98
108
|
class ListResultFailedError < GraphQL::Error
|
@@ -14,18 +14,33 @@ module GraphQL
|
|
14
14
|
# This hash is the one used at runtime.
|
15
15
|
#
|
16
16
|
# @return [Hash<Symbol, Object>]
|
17
|
-
|
17
|
+
def keyword_arguments
|
18
|
+
@keyword_arguments ||= begin
|
19
|
+
kwargs = {}
|
20
|
+
argument_values.each do |name, arg_val|
|
21
|
+
kwargs[name] = arg_val.value
|
22
|
+
end
|
23
|
+
kwargs
|
24
|
+
end
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
27
|
+
# @param argument_values [nil, Hash{Symbol => ArgumentValue}]
|
28
|
+
def initialize(argument_values:)
|
21
29
|
@argument_values = argument_values
|
30
|
+
@empty = argument_values.nil? || argument_values.empty?
|
22
31
|
end
|
23
32
|
|
24
33
|
# @return [Hash{Symbol => ArgumentValue}]
|
25
|
-
|
34
|
+
def argument_values
|
35
|
+
@argument_values ||= {}
|
36
|
+
end
|
37
|
+
|
38
|
+
def empty?
|
39
|
+
@empty
|
40
|
+
end
|
26
41
|
|
27
|
-
def_delegators
|
28
|
-
def_delegators
|
42
|
+
def_delegators :keyword_arguments, :key?, :[], :fetch, :keys, :each, :values
|
43
|
+
def_delegators :argument_values, :each_value
|
29
44
|
|
30
45
|
def inspect
|
31
46
|
"#<#{self.class} @keyword_arguments=#{keyword_arguments.inspect}>"
|
@@ -29,11 +29,16 @@ module GraphQL
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
+
NO_ARGUMENTS = {}.freeze
|
33
|
+
|
32
34
|
NO_VALUE_GIVEN = Object.new
|
33
35
|
|
34
36
|
def prepare_args_hash(ast_arg_or_hash_or_value)
|
35
37
|
case ast_arg_or_hash_or_value
|
36
38
|
when Hash
|
39
|
+
if ast_arg_or_hash_or_value.empty?
|
40
|
+
return NO_ARGUMENTS
|
41
|
+
end
|
37
42
|
args_hash = {}
|
38
43
|
ast_arg_or_hash_or_value.each do |k, v|
|
39
44
|
args_hash[k] = prepare_args_hash(v)
|
@@ -42,6 +47,9 @@ module GraphQL
|
|
42
47
|
when Array
|
43
48
|
ast_arg_or_hash_or_value.map { |v| prepare_args_hash(v) }
|
44
49
|
when GraphQL::Language::Nodes::Field, GraphQL::Language::Nodes::InputObject, GraphQL::Language::Nodes::Directive
|
50
|
+
if ast_arg_or_hash_or_value.arguments.empty?
|
51
|
+
return NO_ARGUMENTS
|
52
|
+
end
|
45
53
|
args_hash = {}
|
46
54
|
ast_arg_or_hash_or_value.arguments.each do |arg|
|
47
55
|
v = prepare_args_hash(arg.value)
|
@@ -43,23 +43,24 @@ module GraphQL
|
|
43
43
|
# might be stored up in lazies.
|
44
44
|
# @return [void]
|
45
45
|
def run_eager
|
46
|
-
|
47
46
|
root_operation = query.selected_operation
|
48
47
|
root_op_type = root_operation.operation_type || "query"
|
49
48
|
root_type = schema.root_type_for_operation(root_op_type)
|
50
49
|
path = []
|
51
|
-
|
52
|
-
@interpreter_context[:current_path] = path
|
50
|
+
set_all_interpreter_context(query.root_value, nil, nil, path)
|
53
51
|
object_proxy = authorized_new(root_type, query.root_value, context, path)
|
54
52
|
object_proxy = schema.sync_lazy(object_proxy)
|
55
53
|
if object_proxy.nil?
|
56
54
|
# Root .authorized? returned false.
|
57
55
|
write_in_response(path, nil)
|
58
|
-
nil
|
59
56
|
else
|
60
57
|
evaluate_selections(path, context.scoped_context, object_proxy, root_type, root_operation.selections, root_operation_type: root_op_type)
|
61
|
-
nil
|
62
58
|
end
|
59
|
+
delete_interpreter_context(:current_path)
|
60
|
+
delete_interpreter_context(:current_field)
|
61
|
+
delete_interpreter_context(:current_object)
|
62
|
+
delete_interpreter_context(:current_arguments)
|
63
|
+
nil
|
63
64
|
end
|
64
65
|
|
65
66
|
def gather_selections(owner_object, owner_type, selections, selections_by_name)
|
@@ -116,9 +117,10 @@ module GraphQL
|
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
120
|
+
NO_ARGS = {}.freeze
|
121
|
+
|
119
122
|
def evaluate_selections(path, scoped_context, owner_object, owner_type, selections, root_operation_type: nil)
|
120
|
-
|
121
|
-
@interpreter_context[:current_path] = path
|
123
|
+
set_all_interpreter_context(owner_object, nil, nil, path)
|
122
124
|
selections_by_name = {}
|
123
125
|
gather_selections(owner_object, owner_type, selections, selections_by_name)
|
124
126
|
selections_by_name.each do |result_name, field_ast_nodes_or_ast_node|
|
@@ -157,8 +159,7 @@ module GraphQL
|
|
157
159
|
# to propagate `null`
|
158
160
|
set_type_at_path(next_path, return_type)
|
159
161
|
# Set this before calling `run_with_directives`, so that the directive can have the latest path
|
160
|
-
|
161
|
-
@interpreter_context[:current_field] = field_defn
|
162
|
+
set_all_interpreter_context(nil, field_defn, nil, next_path)
|
162
163
|
|
163
164
|
context.scoped_context = scoped_context
|
164
165
|
object = owner_object
|
@@ -169,44 +170,50 @@ module GraphQL
|
|
169
170
|
|
170
171
|
begin
|
171
172
|
kwarg_arguments = arguments(object, field_defn, ast_node)
|
172
|
-
rescue GraphQL::ExecutionError => e
|
173
|
+
rescue GraphQL::ExecutionError, GraphQL::UnauthorizedError => e
|
173
174
|
continue_value(next_path, e, owner_type, field_defn, return_type.non_null?, ast_node)
|
174
175
|
next
|
175
176
|
end
|
176
177
|
|
177
178
|
after_lazy(kwarg_arguments, owner: owner_type, field: field_defn, path: next_path, scoped_context: context.scoped_context, owner_object: object, arguments: kwarg_arguments) do |resolved_arguments|
|
178
|
-
|
179
|
+
case resolved_arguments
|
180
|
+
when GraphQL::ExecutionError, GraphQL::UnauthorizedError
|
179
181
|
continue_value(next_path, resolved_arguments, owner_type, field_defn, return_type.non_null?, ast_node)
|
180
182
|
next
|
181
183
|
end
|
182
184
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
185
|
+
if resolved_arguments.empty? && field_defn.extras.empty?
|
186
|
+
# We can avoid allocating the `{ Symbol => Object }` hash in this case
|
187
|
+
kwarg_arguments = NO_ARGS
|
188
|
+
else
|
189
|
+
kwarg_arguments = resolved_arguments.keyword_arguments
|
190
|
+
|
191
|
+
field_defn.extras.each do |extra|
|
192
|
+
case extra
|
193
|
+
when :ast_node
|
194
|
+
kwarg_arguments[:ast_node] = ast_node
|
195
|
+
when :execution_errors
|
196
|
+
kwarg_arguments[:execution_errors] = ExecutionErrors.new(context, ast_node, next_path)
|
197
|
+
when :path
|
198
|
+
kwarg_arguments[:path] = next_path
|
199
|
+
when :lookahead
|
200
|
+
if !field_ast_nodes
|
201
|
+
field_ast_nodes = [ast_node]
|
202
|
+
end
|
203
|
+
kwarg_arguments[:lookahead] = Execution::Lookahead.new(
|
204
|
+
query: query,
|
205
|
+
ast_nodes: field_ast_nodes,
|
206
|
+
field: field_defn,
|
207
|
+
)
|
208
|
+
when :argument_details
|
209
|
+
kwarg_arguments[:argument_details] = resolved_arguments
|
210
|
+
else
|
211
|
+
kwarg_arguments[extra] = field_defn.fetch_extra(extra, context)
|
196
212
|
end
|
197
|
-
kwarg_arguments[:lookahead] = Execution::Lookahead.new(
|
198
|
-
query: query,
|
199
|
-
ast_nodes: field_ast_nodes,
|
200
|
-
field: field_defn,
|
201
|
-
)
|
202
|
-
when :argument_details
|
203
|
-
kwarg_arguments[:argument_details] = resolved_arguments
|
204
|
-
else
|
205
|
-
kwarg_arguments[extra] = field_defn.fetch_extra(extra, context)
|
206
213
|
end
|
207
214
|
end
|
208
215
|
|
209
|
-
|
216
|
+
set_all_interpreter_context(nil, nil, kwarg_arguments, nil)
|
210
217
|
|
211
218
|
# Optimize for the case that field is selected only once
|
212
219
|
if field_ast_nodes.nil? || field_ast_nodes.size == 1
|
@@ -412,6 +419,21 @@ module GraphQL
|
|
412
419
|
true
|
413
420
|
end
|
414
421
|
|
422
|
+
def set_all_interpreter_context(object, field, arguments, path)
|
423
|
+
if object
|
424
|
+
@context[:current_object] = @interpreter_context[:current_object] = object
|
425
|
+
end
|
426
|
+
if field
|
427
|
+
@context[:current_field] = @interpreter_context[:current_field] = field
|
428
|
+
end
|
429
|
+
if arguments
|
430
|
+
@context[:current_arguments] = @interpreter_context[:current_arguments] = arguments
|
431
|
+
end
|
432
|
+
if path
|
433
|
+
@context[:current_path] = @interpreter_context[:current_path] = path
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
415
437
|
# @param obj [Object] Some user-returned value that may want to be batched
|
416
438
|
# @param path [Array<String>]
|
417
439
|
# @param field [GraphQL::Schema::Field]
|
@@ -419,16 +441,10 @@ module GraphQL
|
|
419
441
|
# @param trace [Boolean] If `false`, don't wrap this with field tracing
|
420
442
|
# @return [GraphQL::Execution::Lazy, Object] If loading `object` will be deferred, it's a wrapper over it.
|
421
443
|
def after_lazy(lazy_obj, owner:, field:, path:, scoped_context:, owner_object:, arguments:, eager: false, trace: true, &block)
|
422
|
-
|
423
|
-
@interpreter_context[:current_arguments] = arguments
|
424
|
-
@interpreter_context[:current_path] = path
|
425
|
-
@interpreter_context[:current_field] = field
|
444
|
+
set_all_interpreter_context(owner_object, field, arguments, path)
|
426
445
|
if schema.lazy?(lazy_obj)
|
427
446
|
lazy = GraphQL::Execution::Lazy.new(path: path, field: field) do
|
428
|
-
|
429
|
-
@interpreter_context[:current_field] = field
|
430
|
-
@interpreter_context[:current_object] = owner_object
|
431
|
-
@interpreter_context[:current_arguments] = arguments
|
447
|
+
set_all_interpreter_context(owner_object, field, arguments, path)
|
432
448
|
context.scoped_context = scoped_context
|
433
449
|
# Wrap the execution of _this_ method with tracing,
|
434
450
|
# but don't wrap the continuation below
|
@@ -539,6 +555,18 @@ module GraphQL
|
|
539
555
|
res && res[:__dead]
|
540
556
|
end
|
541
557
|
|
558
|
+
# Set this pair in the Query context, but also in the interpeter namespace,
|
559
|
+
# for compatibility.
|
560
|
+
def set_interpreter_context(key, value)
|
561
|
+
@interpreter_context[key] = value
|
562
|
+
@context[key] = value
|
563
|
+
end
|
564
|
+
|
565
|
+
def delete_interpreter_context(key)
|
566
|
+
@interpreter_context.delete(key)
|
567
|
+
@context.delete(key)
|
568
|
+
end
|
569
|
+
|
542
570
|
def resolve_type(type, value, path)
|
543
571
|
trace_payload = { context: context, type: type, object: value, path: path }
|
544
572
|
resolved_type, resolved_value = query.trace("resolve_type", trace_payload) do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
# This error is raised when `Types::Int` is given an input value outside of 32-bit integer range.
|
4
|
+
#
|
5
|
+
# For really big integer values, consider `GraphQL::Types::BigInt`
|
6
|
+
#
|
7
|
+
# @see GraphQL::Types::Int which raises this error
|
8
|
+
class IntegerDecodingError < GraphQL::RuntimeTypeError
|
9
|
+
# The value which couldn't be decoded
|
10
|
+
attr_reader :integer_value
|
11
|
+
|
12
|
+
def initialize(value)
|
13
|
+
@integer_value = value
|
14
|
+
super("Integer out of bounds: #{value}. \nConsider using GraphQL::Types::BigInt instead.")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,6 +1,102 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module GraphQL
|
3
3
|
module Introspection
|
4
|
+
def self.query(include_deprecated_args: false)
|
5
|
+
# The introspection query to end all introspection queries, copied from
|
6
|
+
# https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js
|
7
|
+
<<-QUERY
|
8
|
+
query IntrospectionQuery {
|
9
|
+
__schema {
|
10
|
+
queryType { name }
|
11
|
+
mutationType { name }
|
12
|
+
subscriptionType { name }
|
13
|
+
types {
|
14
|
+
...FullType
|
15
|
+
}
|
16
|
+
directives {
|
17
|
+
name
|
18
|
+
description
|
19
|
+
locations
|
20
|
+
args {
|
21
|
+
...InputValue
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
fragment FullType on __Type {
|
27
|
+
kind
|
28
|
+
name
|
29
|
+
description
|
30
|
+
fields(includeDeprecated: true) {
|
31
|
+
name
|
32
|
+
description
|
33
|
+
args#{include_deprecated_args ? '(includeDeprecated: true)' : ''} {
|
34
|
+
...InputValue
|
35
|
+
}
|
36
|
+
type {
|
37
|
+
...TypeRef
|
38
|
+
}
|
39
|
+
isDeprecated
|
40
|
+
deprecationReason
|
41
|
+
}
|
42
|
+
inputFields#{include_deprecated_args ? '(includeDeprecated: true)' : ''} {
|
43
|
+
...InputValue
|
44
|
+
}
|
45
|
+
interfaces {
|
46
|
+
...TypeRef
|
47
|
+
}
|
48
|
+
enumValues(includeDeprecated: true) {
|
49
|
+
name
|
50
|
+
description
|
51
|
+
isDeprecated
|
52
|
+
deprecationReason
|
53
|
+
}
|
54
|
+
possibleTypes {
|
55
|
+
...TypeRef
|
56
|
+
}
|
57
|
+
}
|
58
|
+
fragment InputValue on __InputValue {
|
59
|
+
name
|
60
|
+
description
|
61
|
+
type { ...TypeRef }
|
62
|
+
defaultValue
|
63
|
+
#{include_deprecated_args ? 'isDeprecated' : ''}
|
64
|
+
#{include_deprecated_args ? 'deprecationReason' : ''}
|
65
|
+
}
|
66
|
+
fragment TypeRef on __Type {
|
67
|
+
kind
|
68
|
+
name
|
69
|
+
ofType {
|
70
|
+
kind
|
71
|
+
name
|
72
|
+
ofType {
|
73
|
+
kind
|
74
|
+
name
|
75
|
+
ofType {
|
76
|
+
kind
|
77
|
+
name
|
78
|
+
ofType {
|
79
|
+
kind
|
80
|
+
name
|
81
|
+
ofType {
|
82
|
+
kind
|
83
|
+
name
|
84
|
+
ofType {
|
85
|
+
kind
|
86
|
+
name
|
87
|
+
ofType {
|
88
|
+
kind
|
89
|
+
name
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
QUERY
|
99
|
+
end
|
4
100
|
end
|
5
101
|
end
|
6
102
|
|