graphql 1.13.23 → 2.0.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/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +1 -1
- data/lib/graphql/analysis/ast.rb +0 -10
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +0 -18
- data/lib/graphql/backtrace/tracer.rb +1 -2
- data/lib/graphql/backtrace.rb +2 -8
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +1 -9
- data/lib/graphql/execution/interpreter/runtime.rb +6 -13
- data/lib/graphql/execution/interpreter.rb +0 -22
- data/lib/graphql/execution/lazy.rb +1 -1
- data/lib/graphql/execution/lookahead.rb +6 -13
- data/lib/graphql/execution/multiplex.rb +50 -107
- data/lib/graphql/execution.rb +11 -3
- data/lib/graphql/introspection/directive_type.rb +2 -2
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +5 -5
- data/lib/graphql/language/document_from_schema_definition.rb +0 -17
- data/lib/graphql/pagination/connections.rb +2 -28
- data/lib/graphql/query/context.rb +1 -185
- data/lib/graphql/query/input_validation_result.rb +0 -9
- data/lib/graphql/query/literal_input.rb +8 -13
- data/lib/graphql/query/validation_pipeline.rb +6 -34
- data/lib/graphql/query/variable_validation_error.rb +2 -2
- data/lib/graphql/query/variables.rb +8 -31
- data/lib/graphql/query.rb +5 -34
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/relay/range_add.rb +0 -4
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +1 -8
- data/lib/graphql/schema/argument.rb +1 -25
- data/lib/graphql/schema/build_from_definition.rb +0 -1
- data/lib/graphql/schema/directive.rb +1 -22
- data/lib/graphql/schema/enum.rb +3 -19
- data/lib/graphql/schema/enum_value.rb +0 -22
- data/lib/graphql/schema/field.rb +22 -220
- data/lib/graphql/schema/input_object.rb +11 -57
- data/lib/graphql/schema/interface.rb +1 -30
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +2 -2
- data/lib/graphql/schema/list.rb +3 -24
- data/lib/graphql/schema/loader.rb +0 -1
- data/lib/graphql/schema/member/base_dsl_methods.rb +1 -6
- data/lib/graphql/schema/member/build_type.rb +4 -6
- data/lib/graphql/schema/member/has_arguments.rb +16 -20
- data/lib/graphql/schema/member/has_fields.rb +3 -3
- data/lib/graphql/schema/member/has_interfaces.rb +1 -13
- data/lib/graphql/schema/member/validates_input.rb +2 -2
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +3 -9
- data/lib/graphql/schema/object.rb +0 -40
- data/lib/graphql/schema/relay_classic_mutation.rb +17 -28
- data/lib/graphql/schema/scalar.rb +1 -16
- data/lib/graphql/schema/union.rb +0 -16
- data/lib/graphql/schema/warden.rb +3 -12
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +106 -945
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/validator.rb +2 -24
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +1 -1
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +4 -13
- data/lib/graphql/tracing/data_dog_tracing.rb +16 -20
- data/lib/graphql/tracing/platform_tracing.rb +4 -32
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +2 -6
- data/lib/graphql/types/relay/default_relay.rb +0 -10
- data/lib/graphql/types/relay/node_behaviors.rb +5 -1
- data/lib/graphql/types/relay.rb +0 -2
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +1 -66
- metadata +28 -167
- data/lib/graphql/analysis/analyze_query.rb +0 -98
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
- data/lib/graphql/backwards_compatibility.rb +0 -61
- data/lib/graphql/base_type.rb +0 -232
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -436
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -255
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -55
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -133
- data/lib/graphql/execution/execute.rb +0 -333
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -226
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -128
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -138
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -72
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -130
- data/lib/graphql/query/arguments.rb +0 -189
- data/lib/graphql/query/arguments_cache.rb +0 -24
- data/lib/graphql/query/executor.rb +0 -52
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -40
- data/lib/graphql/relay/array_connection.rb +0 -83
- data/lib/graphql/relay/base_connection.rb +0 -189
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -54
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -39
- data/lib/graphql/relay/global_id_resolve.rb +0 -17
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -106
- data/lib/graphql/relay/node.rb +0 -39
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -188
- data/lib/graphql/relay/type_extensions.rb +0 -32
- data/lib/graphql/scalar_type.rb +0 -91
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -17
- data/lib/graphql/schema/member/accepts_definition.rb +0 -164
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
- data/lib/graphql/schema/member/instrumentation.rb +0 -131
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -44
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -88
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -313
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -76
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- data/lib/graphql/types/relay/node_field.rb +0 -24
- data/lib/graphql/types/relay/nodes_field.rb +0 -43
- data/lib/graphql/union_type.rb +0 -115
- data/lib/graphql/upgrader/member.rb +0 -937
- data/lib/graphql/upgrader/schema.rb +0 -38
@@ -1,682 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Compatibility
|
4
|
-
# This asserts that a given parse function turns a string into
|
5
|
-
# the proper tree of {{GraphQL::Language::Nodes}}.
|
6
|
-
module SchemaParserSpecification
|
7
|
-
# @yieldparam query_string [String] A query string to parse
|
8
|
-
# @yieldreturn [GraphQL::Language::Nodes::Document]
|
9
|
-
# @return [Class<Minitest::Test>] A test suite for this parse function
|
10
|
-
def self.build_suite(&block)
|
11
|
-
GraphQL::Deprecation.warn "#{self} will be removed from GraphQL-Ruby 2.0. There is no replacement, please open an issue on GitHub if you need support."
|
12
|
-
|
13
|
-
Class.new(Minitest::Test) do
|
14
|
-
@@parse_fn = block
|
15
|
-
|
16
|
-
def parse(query_string)
|
17
|
-
@@parse_fn.call(query_string)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_it_parses_object_types
|
21
|
-
document = parse('
|
22
|
-
# This is what
|
23
|
-
# somebody said about something
|
24
|
-
type Comment implements Node @deprecated(reason: "No longer supported") {
|
25
|
-
id: ID!
|
26
|
-
}
|
27
|
-
')
|
28
|
-
|
29
|
-
type = document.definitions.first
|
30
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeDefinition, type.class
|
31
|
-
assert_equal 'Comment', type.name
|
32
|
-
assert_equal "This is what\nsomebody said about something", type.description
|
33
|
-
assert_equal ['Node'], type.interfaces.map(&:name)
|
34
|
-
assert_equal ['id'], type.fields.map(&:name)
|
35
|
-
assert_equal [], type.fields[0].arguments
|
36
|
-
assert_equal 'ID', type.fields[0].type.of_type.name
|
37
|
-
assert_equal 1, type.directives.length
|
38
|
-
|
39
|
-
deprecated_directive = type.directives[0]
|
40
|
-
assert_equal 'deprecated', deprecated_directive.name
|
41
|
-
assert_equal 'reason', deprecated_directive.arguments[0].name
|
42
|
-
assert_equal 'No longer supported', deprecated_directive.arguments[0].value
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_it_parses_scalars
|
46
|
-
document = parse('scalar DateTime')
|
47
|
-
|
48
|
-
type = document.definitions.first
|
49
|
-
assert_equal GraphQL::Language::Nodes::ScalarTypeDefinition, type.class
|
50
|
-
assert_equal 'DateTime', type.name
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_it_parses_enum_types
|
54
|
-
document = parse('
|
55
|
-
enum DogCommand {
|
56
|
-
# Good dog
|
57
|
-
SIT
|
58
|
-
DOWN @deprecated(reason: "No longer supported")
|
59
|
-
HEEL
|
60
|
-
}
|
61
|
-
')
|
62
|
-
|
63
|
-
type = document.definitions.first
|
64
|
-
assert_equal GraphQL::Language::Nodes::EnumTypeDefinition, type.class
|
65
|
-
assert_equal 'DogCommand', type.name
|
66
|
-
assert_equal 3, type.values.length
|
67
|
-
|
68
|
-
assert_equal 'SIT', type.values[0].name
|
69
|
-
assert_equal [], type.values[0].directives
|
70
|
-
assert_equal "Good dog", type.values[0].description
|
71
|
-
|
72
|
-
assert_equal 'DOWN', type.values[1].name
|
73
|
-
assert_equal 1, type.values[1].directives.length
|
74
|
-
deprecated_directive = type.values[1].directives[0]
|
75
|
-
assert_equal 'deprecated', deprecated_directive.name
|
76
|
-
assert_equal 'reason', deprecated_directive.arguments[0].name
|
77
|
-
assert_equal 'No longer supported', deprecated_directive.arguments[0].value
|
78
|
-
|
79
|
-
assert_equal 'HEEL', type.values[2].name
|
80
|
-
assert_equal [], type.values[2].directives
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_it_parses_union_types
|
84
|
-
document = parse(
|
85
|
-
"union BagOfThings = \n" \
|
86
|
-
"A |\n" \
|
87
|
-
"B |\n" \
|
88
|
-
"C"
|
89
|
-
)
|
90
|
-
|
91
|
-
union = document.definitions.first
|
92
|
-
|
93
|
-
assert_equal GraphQL::Language::Nodes::UnionTypeDefinition, union.class
|
94
|
-
assert_equal 'BagOfThings', union.name
|
95
|
-
assert_equal 3, union.types.length
|
96
|
-
assert_equal [1, 1], union.position
|
97
|
-
|
98
|
-
assert_equal GraphQL::Language::Nodes::TypeName, union.types[0].class
|
99
|
-
assert_equal 'A', union.types[0].name
|
100
|
-
assert_equal [2, 1], union.types[0].position
|
101
|
-
|
102
|
-
assert_equal GraphQL::Language::Nodes::TypeName, union.types[1].class
|
103
|
-
assert_equal 'B', union.types[1].name
|
104
|
-
assert_equal [3, 1], union.types[1].position
|
105
|
-
|
106
|
-
assert_equal GraphQL::Language::Nodes::TypeName, union.types[2].class
|
107
|
-
assert_equal 'C', union.types[2].name
|
108
|
-
assert_equal [4, 1], union.types[2].position
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_it_parses_input_types
|
112
|
-
document = parse('
|
113
|
-
input EmptyMutationInput {
|
114
|
-
clientMutationId: String
|
115
|
-
}
|
116
|
-
')
|
117
|
-
|
118
|
-
type = document.definitions.first
|
119
|
-
assert_equal GraphQL::Language::Nodes::InputObjectTypeDefinition, type.class
|
120
|
-
assert_equal 'EmptyMutationInput', type.name
|
121
|
-
assert_equal ['clientMutationId'], type.fields.map(&:name)
|
122
|
-
assert_equal 'String', type.fields[0].type.name
|
123
|
-
assert_equal nil, type.fields[0].default_value
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_it_parses_directives
|
127
|
-
document = parse('
|
128
|
-
directive @include(if: Boolean!)
|
129
|
-
on FIELD
|
130
|
-
| FRAGMENT_SPREAD
|
131
|
-
| INLINE_FRAGMENT
|
132
|
-
')
|
133
|
-
|
134
|
-
type = document.definitions.first
|
135
|
-
assert_equal GraphQL::Language::Nodes::DirectiveDefinition, type.class
|
136
|
-
assert_equal 'include', type.name
|
137
|
-
|
138
|
-
assert_equal 1, type.arguments.length
|
139
|
-
assert_equal 'if', type.arguments[0].name
|
140
|
-
assert_equal 'Boolean', type.arguments[0].type.of_type.name
|
141
|
-
|
142
|
-
assert_equal 3, type.locations.length
|
143
|
-
|
144
|
-
assert_instance_of GraphQL::Language::Nodes::DirectiveLocation, type.locations[0]
|
145
|
-
assert_equal 'FIELD', type.locations[0].name
|
146
|
-
assert_equal [3, 20], type.locations[0].position
|
147
|
-
|
148
|
-
assert_instance_of GraphQL::Language::Nodes::DirectiveLocation, type.locations[1]
|
149
|
-
assert_equal 'FRAGMENT_SPREAD', type.locations[1].name
|
150
|
-
assert_equal [4, 19], type.locations[1].position
|
151
|
-
|
152
|
-
assert_instance_of GraphQL::Language::Nodes::DirectiveLocation, type.locations[2]
|
153
|
-
assert_equal 'INLINE_FRAGMENT', type.locations[2].name
|
154
|
-
assert_equal [5, 19], type.locations[2].position
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_it_parses_field_arguments
|
158
|
-
document = parse('
|
159
|
-
type Mutation {
|
160
|
-
post(
|
161
|
-
id: ID! @deprecated(reason: "Not used"),
|
162
|
-
# This is what goes in the post
|
163
|
-
data: String
|
164
|
-
): Post
|
165
|
-
}
|
166
|
-
')
|
167
|
-
|
168
|
-
field = document.definitions.first.fields.first
|
169
|
-
assert_equal ['id', 'data'], field.arguments.map(&:name)
|
170
|
-
id_arg = field.arguments[0]
|
171
|
-
|
172
|
-
deprecated_directive = id_arg.directives[0]
|
173
|
-
assert_equal 'deprecated', deprecated_directive.name
|
174
|
-
assert_equal 'reason', deprecated_directive.arguments[0].name
|
175
|
-
assert_equal 'Not used', deprecated_directive.arguments[0].value
|
176
|
-
|
177
|
-
data_arg = field.arguments[1]
|
178
|
-
assert_equal "data", data_arg.name
|
179
|
-
assert_equal "This is what goes in the post", data_arg.description
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_it_parses_schema_definition
|
183
|
-
document = parse('
|
184
|
-
schema {
|
185
|
-
query: QueryRoot
|
186
|
-
mutation: MutationRoot
|
187
|
-
subscription: SubscriptionRoot
|
188
|
-
}
|
189
|
-
')
|
190
|
-
|
191
|
-
schema = document.definitions.first
|
192
|
-
assert_equal 'QueryRoot', schema.query
|
193
|
-
assert_equal 'MutationRoot', schema.mutation
|
194
|
-
assert_equal 'SubscriptionRoot', schema.subscription
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_it_parses_schema_extensions
|
198
|
-
document = parse('
|
199
|
-
extend schema {
|
200
|
-
query: QueryRoot
|
201
|
-
mutation: MutationRoot
|
202
|
-
subscription: SubscriptionRoot
|
203
|
-
}
|
204
|
-
')
|
205
|
-
|
206
|
-
schema_extension = document.definitions.first
|
207
|
-
assert_equal GraphQL::Language::Nodes::SchemaExtension, schema_extension.class
|
208
|
-
assert_equal [2, 15], schema_extension.position
|
209
|
-
|
210
|
-
assert_equal 'QueryRoot', schema_extension.query
|
211
|
-
assert_equal 'MutationRoot', schema_extension.mutation
|
212
|
-
assert_equal 'SubscriptionRoot', schema_extension.subscription
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_it_parses_schema_extensions_with_directives
|
216
|
-
document = parse('
|
217
|
-
extend schema @something {
|
218
|
-
query: QueryRoot
|
219
|
-
}
|
220
|
-
')
|
221
|
-
|
222
|
-
schema_extension = document.definitions.first
|
223
|
-
assert_equal GraphQL::Language::Nodes::SchemaExtension, schema_extension.class
|
224
|
-
|
225
|
-
assert_equal 1, schema_extension.directives.length
|
226
|
-
assert_equal GraphQL::Language::Nodes::Directive, schema_extension.directives.first.class
|
227
|
-
assert_equal 'something', schema_extension.directives.first.name
|
228
|
-
|
229
|
-
assert_equal 'QueryRoot', schema_extension.query
|
230
|
-
assert_equal nil, schema_extension.mutation
|
231
|
-
assert_equal nil, schema_extension.subscription
|
232
|
-
end
|
233
|
-
|
234
|
-
def test_it_parses_schema_extensions_with_only_directives
|
235
|
-
document = parse('
|
236
|
-
extend schema @something
|
237
|
-
')
|
238
|
-
|
239
|
-
schema_extension = document.definitions.first
|
240
|
-
assert_equal GraphQL::Language::Nodes::SchemaExtension, schema_extension.class
|
241
|
-
|
242
|
-
assert_equal 1, schema_extension.directives.length
|
243
|
-
assert_equal GraphQL::Language::Nodes::Directive, schema_extension.directives.first.class
|
244
|
-
assert_equal 'something', schema_extension.directives.first.name
|
245
|
-
|
246
|
-
assert_equal nil, schema_extension.query
|
247
|
-
assert_equal nil, schema_extension.mutation
|
248
|
-
assert_equal nil, schema_extension.subscription
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_it_parses_scalar_extensions
|
252
|
-
document = parse('
|
253
|
-
extend scalar Date @something @somethingElse
|
254
|
-
')
|
255
|
-
|
256
|
-
scalar_extension = document.definitions.first
|
257
|
-
assert_equal GraphQL::Language::Nodes::ScalarTypeExtension, scalar_extension.class
|
258
|
-
assert_equal 'Date', scalar_extension.name
|
259
|
-
assert_equal [2, 15], scalar_extension.position
|
260
|
-
|
261
|
-
assert_equal 2, scalar_extension.directives.length
|
262
|
-
assert_equal GraphQL::Language::Nodes::Directive, scalar_extension.directives.first.class
|
263
|
-
assert_equal 'something', scalar_extension.directives.first.name
|
264
|
-
assert_equal GraphQL::Language::Nodes::Directive, scalar_extension.directives.last.class
|
265
|
-
assert_equal 'somethingElse', scalar_extension.directives.last.name
|
266
|
-
end
|
267
|
-
|
268
|
-
def test_it_parses_object_type_extensions_with_field_definitions
|
269
|
-
document = parse('
|
270
|
-
extend type User {
|
271
|
-
login: String!
|
272
|
-
}
|
273
|
-
')
|
274
|
-
|
275
|
-
object_type_extension = document.definitions.first
|
276
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
277
|
-
assert_equal 'User', object_type_extension.name
|
278
|
-
assert_equal [2, 15], object_type_extension.position
|
279
|
-
|
280
|
-
assert_equal 1, object_type_extension.fields.length
|
281
|
-
assert_equal GraphQL::Language::Nodes::FieldDefinition, object_type_extension.fields.first.class
|
282
|
-
end
|
283
|
-
|
284
|
-
def test_it_parses_object_type_extensions_with_field_definitions_and_directives
|
285
|
-
document = parse('
|
286
|
-
extend type User @deprecated {
|
287
|
-
login: String!
|
288
|
-
}
|
289
|
-
')
|
290
|
-
|
291
|
-
object_type_extension = document.definitions.first
|
292
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
293
|
-
assert_equal 'User', object_type_extension.name
|
294
|
-
assert_equal [2, 15], object_type_extension.position
|
295
|
-
|
296
|
-
assert_equal 1, object_type_extension.fields.length
|
297
|
-
assert_equal GraphQL::Language::Nodes::FieldDefinition, object_type_extension.fields.first.class
|
298
|
-
|
299
|
-
assert_equal 1, object_type_extension.directives.length
|
300
|
-
assert_equal GraphQL::Language::Nodes::Directive, object_type_extension.directives.first.class
|
301
|
-
end
|
302
|
-
|
303
|
-
def test_it_parses_object_type_extensions_with_field_definitions_and_implements
|
304
|
-
document = parse('
|
305
|
-
extend type User implements Node {
|
306
|
-
login: String!
|
307
|
-
}
|
308
|
-
')
|
309
|
-
|
310
|
-
object_type_extension = document.definitions.first
|
311
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
312
|
-
assert_equal 'User', object_type_extension.name
|
313
|
-
assert_equal [2, 15], object_type_extension.position
|
314
|
-
|
315
|
-
assert_equal 1, object_type_extension.fields.length
|
316
|
-
assert_equal GraphQL::Language::Nodes::FieldDefinition, object_type_extension.fields.first.class
|
317
|
-
|
318
|
-
assert_equal 1, object_type_extension.interfaces.length
|
319
|
-
assert_equal GraphQL::Language::Nodes::TypeName, object_type_extension.interfaces.first.class
|
320
|
-
end
|
321
|
-
|
322
|
-
def test_it_parses_object_type_extensions_with_only_directives
|
323
|
-
document = parse('
|
324
|
-
extend type User @deprecated
|
325
|
-
')
|
326
|
-
|
327
|
-
object_type_extension = document.definitions.first
|
328
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
329
|
-
assert_equal 'User', object_type_extension.name
|
330
|
-
assert_equal [2, 15], object_type_extension.position
|
331
|
-
|
332
|
-
assert_equal 1, object_type_extension.directives.length
|
333
|
-
assert_equal GraphQL::Language::Nodes::Directive, object_type_extension.directives.first.class
|
334
|
-
assert_equal 'deprecated', object_type_extension.directives.first.name
|
335
|
-
end
|
336
|
-
|
337
|
-
def test_it_parses_object_type_extensions_with_implements_and_directives
|
338
|
-
document = parse('
|
339
|
-
extend type User implements Node @deprecated
|
340
|
-
')
|
341
|
-
|
342
|
-
object_type_extension = document.definitions.first
|
343
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
344
|
-
assert_equal 'User', object_type_extension.name
|
345
|
-
assert_equal [2, 15], object_type_extension.position
|
346
|
-
|
347
|
-
assert_equal 1, object_type_extension.directives.length
|
348
|
-
assert_equal GraphQL::Language::Nodes::Directive, object_type_extension.directives.first.class
|
349
|
-
assert_equal 'deprecated', object_type_extension.directives.first.name
|
350
|
-
|
351
|
-
assert_equal 1, object_type_extension.interfaces.length
|
352
|
-
assert_equal GraphQL::Language::Nodes::TypeName, object_type_extension.interfaces.first.class
|
353
|
-
assert_equal 'Node', object_type_extension.interfaces.first.name
|
354
|
-
end
|
355
|
-
|
356
|
-
def test_it_parses_object_type_extensions_with_only_implements
|
357
|
-
document = parse('
|
358
|
-
extend type User implements Node
|
359
|
-
')
|
360
|
-
|
361
|
-
object_type_extension = document.definitions.first
|
362
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeExtension, object_type_extension.class
|
363
|
-
assert_equal 'User', object_type_extension.name
|
364
|
-
assert_equal [2, 15], object_type_extension.position
|
365
|
-
|
366
|
-
assert_equal 1, object_type_extension.interfaces.length
|
367
|
-
assert_equal GraphQL::Language::Nodes::TypeName, object_type_extension.interfaces.first.class
|
368
|
-
assert_equal 'Node', object_type_extension.interfaces.first.name
|
369
|
-
end
|
370
|
-
|
371
|
-
def test_it_parses_interface_type_extensions_with_directives_and_fields
|
372
|
-
document = parse('
|
373
|
-
extend interface Node @directive {
|
374
|
-
field: String
|
375
|
-
}
|
376
|
-
')
|
377
|
-
|
378
|
-
interface_type_extension = document.definitions.first
|
379
|
-
assert_equal GraphQL::Language::Nodes::InterfaceTypeExtension, interface_type_extension.class
|
380
|
-
assert_equal 'Node', interface_type_extension.name
|
381
|
-
assert_equal [2, 15], interface_type_extension.position
|
382
|
-
|
383
|
-
assert_equal 1, interface_type_extension.directives.length
|
384
|
-
assert_equal GraphQL::Language::Nodes::Directive, interface_type_extension.directives.first.class
|
385
|
-
assert_equal 'directive', interface_type_extension.directives.first.name
|
386
|
-
|
387
|
-
assert_equal 1, interface_type_extension.fields.length
|
388
|
-
assert_equal GraphQL::Language::Nodes::FieldDefinition, interface_type_extension.fields.first.class
|
389
|
-
assert_equal 'field', interface_type_extension.fields.first.name
|
390
|
-
end
|
391
|
-
|
392
|
-
def test_it_parses_interface_type_extensions_with_fields
|
393
|
-
document = parse('
|
394
|
-
extend interface Node {
|
395
|
-
field: String
|
396
|
-
}
|
397
|
-
')
|
398
|
-
|
399
|
-
interface_type_extension = document.definitions.first
|
400
|
-
assert_equal GraphQL::Language::Nodes::InterfaceTypeExtension, interface_type_extension.class
|
401
|
-
assert_equal 'Node', interface_type_extension.name
|
402
|
-
assert_equal [2, 15], interface_type_extension.position
|
403
|
-
|
404
|
-
assert_equal 0, interface_type_extension.directives.length
|
405
|
-
|
406
|
-
assert_equal 1, interface_type_extension.fields.length
|
407
|
-
assert_equal GraphQL::Language::Nodes::FieldDefinition, interface_type_extension.fields.first.class
|
408
|
-
assert_equal 'field', interface_type_extension.fields.first.name
|
409
|
-
end
|
410
|
-
|
411
|
-
def test_it_parses_interface_type_extensions_with_directives
|
412
|
-
document = parse('
|
413
|
-
extend interface Node @directive
|
414
|
-
')
|
415
|
-
|
416
|
-
interface_type_extension = document.definitions.first
|
417
|
-
assert_equal GraphQL::Language::Nodes::InterfaceTypeExtension, interface_type_extension.class
|
418
|
-
assert_equal 'Node', interface_type_extension.name
|
419
|
-
assert_equal [2, 15], interface_type_extension.position
|
420
|
-
|
421
|
-
assert_equal 1, interface_type_extension.directives.length
|
422
|
-
assert_equal GraphQL::Language::Nodes::Directive, interface_type_extension.directives.first.class
|
423
|
-
assert_equal 'directive', interface_type_extension.directives.first.name
|
424
|
-
end
|
425
|
-
|
426
|
-
def test_it_parses_union_type_extension_with_union_members
|
427
|
-
document = parse('
|
428
|
-
extend union BagOfThings = A | B
|
429
|
-
')
|
430
|
-
|
431
|
-
union_type_extension = document.definitions.first
|
432
|
-
assert_equal GraphQL::Language::Nodes::UnionTypeExtension, union_type_extension.class
|
433
|
-
assert_equal 'BagOfThings', union_type_extension.name
|
434
|
-
assert_equal [2, 15], union_type_extension.position
|
435
|
-
|
436
|
-
assert_equal 0, union_type_extension.directives.length
|
437
|
-
|
438
|
-
assert_equal 2, union_type_extension.types.length
|
439
|
-
assert_equal GraphQL::Language::Nodes::TypeName, union_type_extension.types.first.class
|
440
|
-
assert_equal 'A', union_type_extension.types.first.name
|
441
|
-
end
|
442
|
-
|
443
|
-
def test_it_parses_union_type_extension_with_directives_and_union_members
|
444
|
-
document = parse('
|
445
|
-
extend union BagOfThings @directive = A | B
|
446
|
-
')
|
447
|
-
|
448
|
-
union_type_extension = document.definitions.first
|
449
|
-
assert_equal GraphQL::Language::Nodes::UnionTypeExtension, union_type_extension.class
|
450
|
-
assert_equal 'BagOfThings', union_type_extension.name
|
451
|
-
assert_equal [2, 15], union_type_extension.position
|
452
|
-
|
453
|
-
assert_equal 1, union_type_extension.directives.length
|
454
|
-
assert_equal GraphQL::Language::Nodes::Directive, union_type_extension.directives.first.class
|
455
|
-
assert_equal 'directive', union_type_extension.directives.first.name
|
456
|
-
|
457
|
-
assert_equal 2, union_type_extension.types.length
|
458
|
-
assert_equal GraphQL::Language::Nodes::TypeName, union_type_extension.types.first.class
|
459
|
-
assert_equal 'A', union_type_extension.types.first.name
|
460
|
-
end
|
461
|
-
|
462
|
-
def test_it_parses_union_type_extension_with_directives
|
463
|
-
document = parse('
|
464
|
-
extend union BagOfThings @directive
|
465
|
-
')
|
466
|
-
|
467
|
-
union_type_extension = document.definitions.first
|
468
|
-
assert_equal GraphQL::Language::Nodes::UnionTypeExtension, union_type_extension.class
|
469
|
-
assert_equal 'BagOfThings', union_type_extension.name
|
470
|
-
assert_equal [2, 15], union_type_extension.position
|
471
|
-
|
472
|
-
assert_equal 1, union_type_extension.directives.length
|
473
|
-
assert_equal GraphQL::Language::Nodes::Directive, union_type_extension.directives.first.class
|
474
|
-
assert_equal 'directive', union_type_extension.directives.first.name
|
475
|
-
|
476
|
-
assert_equal 0, union_type_extension.types.length
|
477
|
-
end
|
478
|
-
|
479
|
-
def test_it_parses_enum_type_extension_with_values
|
480
|
-
document = parse('
|
481
|
-
extend enum Status {
|
482
|
-
DRAFT
|
483
|
-
PUBLISHED
|
484
|
-
}
|
485
|
-
')
|
486
|
-
|
487
|
-
enum_type_extension = document.definitions.first
|
488
|
-
assert_equal GraphQL::Language::Nodes::EnumTypeExtension, enum_type_extension.class
|
489
|
-
assert_equal 'Status', enum_type_extension.name
|
490
|
-
assert_equal [2, 15], enum_type_extension.position
|
491
|
-
|
492
|
-
assert_equal 0, enum_type_extension.directives.length
|
493
|
-
|
494
|
-
assert_equal 2, enum_type_extension.values.length
|
495
|
-
assert_equal GraphQL::Language::Nodes::EnumValueDefinition, enum_type_extension.values.first.class
|
496
|
-
assert_equal 'DRAFT', enum_type_extension.values.first.name
|
497
|
-
end
|
498
|
-
|
499
|
-
def test_it_parses_enum_type_extension_with_directives_and_values
|
500
|
-
document = parse('
|
501
|
-
extend enum Status @directive {
|
502
|
-
DRAFT
|
503
|
-
PUBLISHED
|
504
|
-
}
|
505
|
-
')
|
506
|
-
|
507
|
-
enum_type_extension = document.definitions.first
|
508
|
-
assert_equal GraphQL::Language::Nodes::EnumTypeExtension, enum_type_extension.class
|
509
|
-
assert_equal 'Status', enum_type_extension.name
|
510
|
-
assert_equal [2, 15], enum_type_extension.position
|
511
|
-
|
512
|
-
assert_equal 1, enum_type_extension.directives.length
|
513
|
-
assert_equal GraphQL::Language::Nodes::Directive, enum_type_extension.directives.first.class
|
514
|
-
assert_equal 'directive', enum_type_extension.directives.first.name
|
515
|
-
|
516
|
-
assert_equal 2, enum_type_extension.values.length
|
517
|
-
assert_equal GraphQL::Language::Nodes::EnumValueDefinition, enum_type_extension.values.first.class
|
518
|
-
assert_equal 'DRAFT', enum_type_extension.values.first.name
|
519
|
-
end
|
520
|
-
|
521
|
-
def test_it_parses_enum_type_extension_with_directives
|
522
|
-
document = parse('
|
523
|
-
extend enum Status @directive
|
524
|
-
')
|
525
|
-
|
526
|
-
enum_type_extension = document.definitions.first
|
527
|
-
assert_equal GraphQL::Language::Nodes::EnumTypeExtension, enum_type_extension.class
|
528
|
-
assert_equal 'Status', enum_type_extension.name
|
529
|
-
assert_equal [2, 15], enum_type_extension.position
|
530
|
-
|
531
|
-
assert_equal 1, enum_type_extension.directives.length
|
532
|
-
assert_equal GraphQL::Language::Nodes::Directive, enum_type_extension.directives.first.class
|
533
|
-
assert_equal 'directive', enum_type_extension.directives.first.name
|
534
|
-
|
535
|
-
assert_equal 0, enum_type_extension.values.length
|
536
|
-
end
|
537
|
-
|
538
|
-
def test_it_parses_input_object_type_extension_with_fields
|
539
|
-
document = parse('
|
540
|
-
extend input UserInput {
|
541
|
-
login: String!
|
542
|
-
}
|
543
|
-
')
|
544
|
-
|
545
|
-
input_object_type_extension = document.definitions.first
|
546
|
-
assert_equal GraphQL::Language::Nodes::InputObjectTypeExtension, input_object_type_extension.class
|
547
|
-
assert_equal 'UserInput', input_object_type_extension.name
|
548
|
-
assert_equal [2, 15], input_object_type_extension.position
|
549
|
-
|
550
|
-
assert_equal 1, input_object_type_extension.fields.length
|
551
|
-
assert_equal GraphQL::Language::Nodes::InputValueDefinition, input_object_type_extension.fields.first.class
|
552
|
-
assert_equal 'login', input_object_type_extension.fields.first.name
|
553
|
-
|
554
|
-
assert_equal 0, input_object_type_extension.directives.length
|
555
|
-
end
|
556
|
-
|
557
|
-
def test_it_parses_input_object_type_extension_with_directives_and_fields
|
558
|
-
document = parse('
|
559
|
-
extend input UserInput @deprecated {
|
560
|
-
login: String!
|
561
|
-
}
|
562
|
-
')
|
563
|
-
|
564
|
-
input_object_type_extension = document.definitions.first
|
565
|
-
assert_equal GraphQL::Language::Nodes::InputObjectTypeExtension, input_object_type_extension.class
|
566
|
-
assert_equal 'UserInput', input_object_type_extension.name
|
567
|
-
assert_equal [2, 15], input_object_type_extension.position
|
568
|
-
|
569
|
-
assert_equal 1, input_object_type_extension.fields.length
|
570
|
-
assert_equal GraphQL::Language::Nodes::InputValueDefinition, input_object_type_extension.fields.first.class
|
571
|
-
assert_equal 'login', input_object_type_extension.fields.first.name
|
572
|
-
|
573
|
-
assert_equal 1, input_object_type_extension.directives.length
|
574
|
-
assert_equal GraphQL::Language::Nodes::Directive, input_object_type_extension.directives.first.class
|
575
|
-
assert_equal 'deprecated', input_object_type_extension.directives.first.name
|
576
|
-
end
|
577
|
-
|
578
|
-
def test_it_parses_input_object_type_extension_with_directives
|
579
|
-
document = parse('
|
580
|
-
extend input UserInput @deprecated
|
581
|
-
')
|
582
|
-
|
583
|
-
input_object_type_extension = document.definitions.first
|
584
|
-
assert_equal GraphQL::Language::Nodes::InputObjectTypeExtension, input_object_type_extension.class
|
585
|
-
assert_equal 'UserInput', input_object_type_extension.name
|
586
|
-
assert_equal [2, 15], input_object_type_extension.position
|
587
|
-
|
588
|
-
assert_equal 0, input_object_type_extension.fields.length
|
589
|
-
|
590
|
-
assert_equal 1, input_object_type_extension.directives.length
|
591
|
-
assert_equal GraphQL::Language::Nodes::Directive, input_object_type_extension.directives.first.class
|
592
|
-
assert_equal 'deprecated', input_object_type_extension.directives.first.name
|
593
|
-
end
|
594
|
-
|
595
|
-
def test_it_parses_whole_definition_with_descriptions
|
596
|
-
document = parse(SCHEMA_DEFINITION_STRING)
|
597
|
-
|
598
|
-
assert_equal 6, document.definitions.size
|
599
|
-
|
600
|
-
schema_definition, directive_definition, enum_type_definition, object_type_definition, input_object_type_definition, interface_type_definition = document.definitions
|
601
|
-
|
602
|
-
assert_equal GraphQL::Language::Nodes::SchemaDefinition, schema_definition.class
|
603
|
-
|
604
|
-
assert_equal GraphQL::Language::Nodes::DirectiveDefinition, directive_definition.class
|
605
|
-
assert_equal 'This is a directive', directive_definition.description
|
606
|
-
|
607
|
-
assert_equal GraphQL::Language::Nodes::EnumTypeDefinition, enum_type_definition.class
|
608
|
-
assert_equal "Multiline comment\n\nWith an enum", enum_type_definition.description
|
609
|
-
|
610
|
-
assert_nil enum_type_definition.values[0].description
|
611
|
-
assert_equal 'Not a creative color', enum_type_definition.values[1].description
|
612
|
-
|
613
|
-
assert_equal GraphQL::Language::Nodes::ObjectTypeDefinition, object_type_definition.class
|
614
|
-
assert_equal 'Comment without preceding space', object_type_definition.description
|
615
|
-
assert_equal 'And a field to boot', object_type_definition.fields[0].description
|
616
|
-
|
617
|
-
assert_equal GraphQL::Language::Nodes::InputObjectTypeDefinition, input_object_type_definition.class
|
618
|
-
assert_equal 'Comment for input object types', input_object_type_definition.description
|
619
|
-
assert_equal 'Color of the car', input_object_type_definition.fields[0].description
|
620
|
-
|
621
|
-
assert_equal GraphQL::Language::Nodes::InterfaceTypeDefinition, interface_type_definition.class
|
622
|
-
assert_equal 'Comment for interface definitions', interface_type_definition.description
|
623
|
-
assert_equal 'Amount of wheels', interface_type_definition.fields[0].description
|
624
|
-
|
625
|
-
brand_field = interface_type_definition.fields[1]
|
626
|
-
assert_equal 1, brand_field.arguments.length
|
627
|
-
assert_equal 'argument', brand_field.arguments[0].name
|
628
|
-
assert_instance_of GraphQL::Language::Nodes::NullValue, brand_field.arguments[0].default_value
|
629
|
-
end
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
SCHEMA_DEFINITION_STRING = %|
|
634
|
-
# Schema at beginning of file
|
635
|
-
|
636
|
-
schema {
|
637
|
-
query: Hello
|
638
|
-
}
|
639
|
-
|
640
|
-
# Comment between two definitions are omitted
|
641
|
-
|
642
|
-
# This is a directive
|
643
|
-
directive @foo(
|
644
|
-
# It has an argument
|
645
|
-
arg: Int
|
646
|
-
) on FIELD
|
647
|
-
|
648
|
-
# Multiline comment
|
649
|
-
#
|
650
|
-
# With an enum
|
651
|
-
enum Color {
|
652
|
-
RED
|
653
|
-
|
654
|
-
# Not a creative color
|
655
|
-
GREEN
|
656
|
-
BLUE
|
657
|
-
}
|
658
|
-
|
659
|
-
#Comment without preceding space
|
660
|
-
type Hello {
|
661
|
-
# And a field to boot
|
662
|
-
str: String
|
663
|
-
}
|
664
|
-
|
665
|
-
# Comment for input object types
|
666
|
-
input Car {
|
667
|
-
# Color of the car
|
668
|
-
color: String!
|
669
|
-
}
|
670
|
-
|
671
|
-
# Comment for interface definitions
|
672
|
-
interface Vehicle {
|
673
|
-
# Amount of wheels
|
674
|
-
wheels: Int!
|
675
|
-
brand(argument: String = null): String!
|
676
|
-
}
|
677
|
-
|
678
|
-
# Comment at the end of schema
|
679
|
-
|
|
680
|
-
end
|
681
|
-
end
|
682
|
-
end
|
@@ -1,5 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "graphql/compatibility/execution_specification"
|
3
|
-
require "graphql/compatibility/lazy_execution_specification"
|
4
|
-
require "graphql/compatibility/query_parser_specification"
|
5
|
-
require "graphql/compatibility/schema_parser_specification"
|