graphql 1.13.19 → 2.0.19
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/install_generator.rb +1 -1
- data/lib/generators/graphql/relay.rb +3 -17
- data/lib/generators/graphql/templates/schema.erb +3 -0
- data/lib/graphql/analysis/ast/field_usage.rb +3 -1
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- 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 +43 -36
- data/lib/graphql/analysis/ast.rb +2 -12
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +2 -20
- data/lib/graphql/backtrace/tracer.rb +2 -3
- data/lib/graphql/backtrace.rb +2 -8
- data/lib/graphql/dataloader/null_dataloader.rb +3 -1
- data/lib/graphql/dataloader/source.rb +9 -0
- data/lib/graphql/dataloader.rb +4 -1
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +12 -82
- data/lib/graphql/execution/interpreter/resolve.rb +26 -0
- data/lib/graphql/execution/interpreter/runtime.rb +162 -119
- data/lib/graphql/execution/interpreter.rb +187 -78
- data/lib/graphql/execution/lazy.rb +7 -21
- data/lib/graphql/execution/lookahead.rb +44 -40
- data/lib/graphql/execution/multiplex.rb +3 -174
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/introspection/type_type.rb +8 -1
- data/lib/graphql/introspection.rb +4 -3
- data/lib/graphql/language/document_from_schema_definition.rb +18 -35
- data/lib/graphql/language/lexer.rb +216 -1488
- data/lib/graphql/language/lexer.ri +744 -0
- data/lib/graphql/language/nodes.rb +41 -33
- data/lib/graphql/language/parser.rb +375 -363
- data/lib/graphql/language/parser.y +48 -43
- data/lib/graphql/language/printer.rb +37 -21
- data/lib/graphql/language/visitor.rb +191 -83
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/pagination/array_connection.rb +4 -2
- data/lib/graphql/pagination/connection.rb +31 -4
- data/lib/graphql/pagination/connections.rb +3 -28
- data/lib/graphql/pagination/relation_connection.rb +2 -0
- data/lib/graphql/query/context.rb +155 -196
- data/lib/graphql/query/input_validation_result.rb +1 -1
- data/lib/graphql/query/null_context.rb +0 -3
- data/lib/graphql/query/validation_pipeline.rb +10 -34
- data/lib/graphql/query/variables.rb +7 -20
- data/lib/graphql/query.rb +32 -42
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/rake_task/validate.rb +1 -1
- data/lib/graphql/rake_task.rb +29 -1
- data/lib/graphql/relay/range_add.rb +9 -20
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +7 -9
- data/lib/graphql/schema/argument.rb +36 -43
- data/lib/graphql/schema/build_from_definition.rb +32 -18
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/transform.rb +1 -1
- data/lib/graphql/schema/directive.rb +11 -22
- data/lib/graphql/schema/enum.rb +28 -39
- data/lib/graphql/schema/enum_value.rb +5 -25
- data/lib/graphql/schema/field/connection_extension.rb +4 -0
- data/lib/graphql/schema/field.rb +214 -327
- data/lib/graphql/schema/input_object.rb +56 -67
- data/lib/graphql/schema/interface.rb +0 -35
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +8 -2
- data/lib/graphql/schema/list.rb +0 -6
- data/lib/graphql/schema/loader.rb +1 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +15 -19
- data/lib/graphql/schema/member/build_type.rb +5 -7
- data/lib/graphql/schema/member/has_arguments.rb +144 -53
- data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
- data/lib/graphql/schema/member/has_directives.rb +71 -56
- data/lib/graphql/schema/member/has_fields.rb +15 -3
- data/lib/graphql/schema/member/has_interfaces.rb +47 -18
- data/lib/graphql/schema/member/has_validators.rb +31 -5
- data/lib/graphql/schema/member/relay_shortcuts.rb +28 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +17 -0
- data/lib/graphql/schema/member/validates_input.rb +1 -1
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +1 -7
- data/lib/graphql/schema/object.rb +15 -52
- data/lib/graphql/schema/relay_classic_mutation.rb +53 -42
- data/lib/graphql/schema/resolver/has_payload_type.rb +20 -10
- data/lib/graphql/schema/resolver.rb +41 -42
- data/lib/graphql/schema/scalar.rb +7 -22
- data/lib/graphql/schema/subscription.rb +0 -7
- data/lib/graphql/schema/timeout.rb +24 -28
- data/lib/graphql/schema/type_membership.rb +3 -0
- data/lib/graphql/schema/union.rb +10 -17
- data/lib/graphql/schema/warden.rb +23 -6
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +240 -968
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -1
- data/lib/graphql/static_validation/error.rb +2 -2
- data/lib/graphql/static_validation/literal_validator.rb +19 -1
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +11 -5
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +12 -6
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
- data/lib/graphql/static_validation/validator.rb +3 -25
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -1
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +3 -8
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +32 -20
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appsignal_trace.rb +66 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +41 -0
- data/lib/graphql/tracing/platform_trace.rb +107 -0
- data/lib/graphql/tracing/platform_tracing.rb +26 -41
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing.rb +136 -40
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/types/iso_8601_date.rb +4 -1
- data/lib/graphql/types/iso_8601_date_time.rb +4 -0
- data/lib/graphql/types/relay/base_connection.rb +16 -6
- data/lib/graphql/types/relay/connection_behaviors.rb +5 -25
- data/lib/graphql/types/relay/default_relay.rb +5 -9
- data/lib/graphql/types/relay/edge_behaviors.rb +1 -4
- 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 +11 -72
- metadata +31 -132
- 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/instrumentation.rb +0 -92
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- 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/language/lexer.rl +0 -260
- 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/literal_input.rb +0 -136
- 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,266 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "graphql/compatibility/query_parser_specification/query_assertions"
|
3
|
-
require "graphql/compatibility/query_parser_specification/parse_error_specification"
|
4
|
-
|
5
|
-
module GraphQL
|
6
|
-
module Compatibility
|
7
|
-
# This asserts that a given parse function turns a string into
|
8
|
-
# the proper tree of {{GraphQL::Language::Nodes}}.
|
9
|
-
module QueryParserSpecification
|
10
|
-
# @yieldparam query_string [String] A query string to parse
|
11
|
-
# @yieldreturn [GraphQL::Language::Nodes::Document]
|
12
|
-
# @return [Class<Minitest::Test>] A test suite for this parse function
|
13
|
-
def self.build_suite(&block)
|
14
|
-
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."
|
15
|
-
|
16
|
-
Class.new(Minitest::Test) do
|
17
|
-
include QueryAssertions
|
18
|
-
include ParseErrorSpecification
|
19
|
-
|
20
|
-
@@parse_fn = block
|
21
|
-
|
22
|
-
def parse(query_string)
|
23
|
-
@@parse_fn.call(query_string)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_it_parses_queries
|
27
|
-
document = parse(QUERY_STRING)
|
28
|
-
query = document.definitions.first
|
29
|
-
assert_valid_query(query)
|
30
|
-
assert_valid_fragment(document.definitions.last)
|
31
|
-
assert_valid_variable(query.variables.first)
|
32
|
-
field = query.selections.first
|
33
|
-
assert_valid_field(field)
|
34
|
-
assert_valid_variable_argument(field.arguments.first)
|
35
|
-
assert_valid_literal_argument(field.arguments.last)
|
36
|
-
assert_valid_directive(field.directives.first)
|
37
|
-
fragment_spread = query.selections[1].selections.last
|
38
|
-
assert_valid_fragment_spread(fragment_spread)
|
39
|
-
assert_valid_typed_inline_fragment(query.selections[2])
|
40
|
-
assert_valid_typeless_inline_fragment(query.selections[3])
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_it_parses_unnamed_queries
|
44
|
-
document = parse("{ name, age, height }")
|
45
|
-
operation = document.definitions.first
|
46
|
-
assert_equal 1, document.definitions.length
|
47
|
-
assert_equal "query", operation.operation_type
|
48
|
-
assert_equal nil, operation.name
|
49
|
-
assert_equal 3, operation.selections.length
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_it_parses_the_introspection_query
|
53
|
-
parse(GraphQL::Introspection::INTROSPECTION_QUERY)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_it_parses_inputs
|
57
|
-
query_string = %|
|
58
|
-
{
|
59
|
-
field(
|
60
|
-
int: 3,
|
61
|
-
float: 4.7e-24,
|
62
|
-
bool: false,
|
63
|
-
string: "☀︎🏆 \\b \\f \\n \\r \\t \\" \u00b6 \\u00b6 / \\/",
|
64
|
-
enum: ENUM_NAME,
|
65
|
-
array: [7, 8, 9]
|
66
|
-
object: {a: [1,2,3], b: {c: "4"}}
|
67
|
-
unicode_bom: "\xef\xbb\xbfquery"
|
68
|
-
keywordEnum: on
|
69
|
-
nullValue: null
|
70
|
-
nullValueInObject: {a: null, b: "b"}
|
71
|
-
nullValueInArray: ["a", null, "b"]
|
72
|
-
blockString: """
|
73
|
-
Hello,
|
74
|
-
World
|
75
|
-
"""
|
76
|
-
)
|
77
|
-
}
|
78
|
-
|
|
79
|
-
document = parse(query_string)
|
80
|
-
inputs = document.definitions.first.selections.first.arguments
|
81
|
-
assert_equal 3, inputs[0].value, "Integers"
|
82
|
-
assert_equal 0.47e-23, inputs[1].value, "Floats"
|
83
|
-
assert_equal false, inputs[2].value, "Booleans"
|
84
|
-
assert_equal %|☀︎🏆 \b \f \n \r \t " ¶ ¶ / /|, inputs[3].value, "Strings"
|
85
|
-
assert_instance_of GraphQL::Language::Nodes::Enum, inputs[4].value
|
86
|
-
assert_equal "ENUM_NAME", inputs[4].value.name, "Enums"
|
87
|
-
assert_equal [7,8,9], inputs[5].value, "Lists"
|
88
|
-
|
89
|
-
obj = inputs[6].value
|
90
|
-
assert_equal "a", obj.arguments[0].name
|
91
|
-
assert_equal [1,2,3], obj.arguments[0].value
|
92
|
-
assert_equal "b", obj.arguments[1].name
|
93
|
-
assert_equal "c", obj.arguments[1].value.arguments[0].name
|
94
|
-
assert_equal "4", obj.arguments[1].value.arguments[0].value
|
95
|
-
|
96
|
-
assert_equal %|\xef\xbb\xbfquery|, inputs[7].value, "Unicode BOM"
|
97
|
-
assert_equal "on", inputs[8].value.name, "Enum value 'on'"
|
98
|
-
|
99
|
-
assert_instance_of GraphQL::Language::Nodes::NullValue, inputs[9].value
|
100
|
-
|
101
|
-
args = inputs[10].value.arguments
|
102
|
-
assert_instance_of GraphQL::Language::Nodes::NullValue, args.find{ |arg| arg.name == 'a' }.value
|
103
|
-
assert_equal 'b', args.find{ |arg| arg.name == 'b' }.value
|
104
|
-
|
105
|
-
values = inputs[11].value
|
106
|
-
assert_equal 'a', values[0]
|
107
|
-
assert_instance_of GraphQL::Language::Nodes::NullValue, values[1]
|
108
|
-
assert_equal 'b', values[2]
|
109
|
-
|
110
|
-
block_str_value = inputs[12].value
|
111
|
-
assert_equal "Hello,\n World", block_str_value
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_it_doesnt_parse_nonsense_variables
|
115
|
-
query_string_1 = "query Vars($var1) { cheese(id: $var1) { flavor } }"
|
116
|
-
query_string_2 = "query Vars2($var1: Int = $var1) { cheese(id: $var1) { flavor } }"
|
117
|
-
|
118
|
-
err_1 = assert_raises(GraphQL::ParseError) do
|
119
|
-
parse(query_string_1)
|
120
|
-
end
|
121
|
-
assert_equal [1,17], [err_1.line, err_1.col]
|
122
|
-
|
123
|
-
err_2 = assert_raises(GraphQL::ParseError) do
|
124
|
-
parse(query_string_2)
|
125
|
-
end
|
126
|
-
assert_equal [1,26], [err_2.line, err_2.col]
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_enum_value_definitions_have_a_position
|
130
|
-
document = parse("""
|
131
|
-
enum Enum {
|
132
|
-
VALUE
|
133
|
-
}
|
134
|
-
""")
|
135
|
-
|
136
|
-
assert_equal [3, 17], document.definitions[0].values[0].position
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_field_definitions_have_a_position
|
140
|
-
document = parse("""
|
141
|
-
type A {
|
142
|
-
field: String
|
143
|
-
}
|
144
|
-
""")
|
145
|
-
|
146
|
-
assert_equal [3, 17], document.definitions[0].fields[0].position
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_input_value_definitions_have_a_position
|
150
|
-
document = parse("""
|
151
|
-
input A {
|
152
|
-
field: String
|
153
|
-
}
|
154
|
-
""")
|
155
|
-
|
156
|
-
assert_equal [3, 17], document.definitions[0].fields[0].position
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_parses_when_there_are_no_interfaces
|
160
|
-
schema = "
|
161
|
-
type A {
|
162
|
-
a: String
|
163
|
-
}
|
164
|
-
"
|
165
|
-
|
166
|
-
document = parse(schema)
|
167
|
-
|
168
|
-
assert_equal [], document.definitions[0].interfaces.map(&:name)
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_parses_implements_with_leading_ampersand
|
172
|
-
schema = "
|
173
|
-
type A implements & B {
|
174
|
-
a: String
|
175
|
-
}
|
176
|
-
"
|
177
|
-
|
178
|
-
document = parse(schema)
|
179
|
-
|
180
|
-
assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
|
181
|
-
assert_equal [2, 35], document.definitions[0].interfaces[0].position
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_parses_implements_with_leading_ampersand_and_multiple_interfaces
|
185
|
-
schema = "
|
186
|
-
type A implements & B & C {
|
187
|
-
a: String
|
188
|
-
}
|
189
|
-
"
|
190
|
-
|
191
|
-
document = parse(schema)
|
192
|
-
|
193
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
194
|
-
assert_equal [2, 35], document.definitions[0].interfaces[0].position
|
195
|
-
assert_equal [2, 39], document.definitions[0].interfaces[1].position
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_parses_implements_without_leading_ampersand
|
199
|
-
schema = "
|
200
|
-
type A implements B {
|
201
|
-
a: String
|
202
|
-
}
|
203
|
-
"
|
204
|
-
|
205
|
-
document = parse(schema)
|
206
|
-
|
207
|
-
assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
|
208
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_parses_implements_without_leading_ampersand_and_multiple_interfaces
|
212
|
-
schema = "
|
213
|
-
type A implements B & C {
|
214
|
-
a: String
|
215
|
-
}
|
216
|
-
"
|
217
|
-
|
218
|
-
document = parse(schema)
|
219
|
-
|
220
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
221
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
222
|
-
assert_equal [2, 37], document.definitions[0].interfaces[1].position
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_supports_old_syntax_for_parsing_multiple_interfaces
|
226
|
-
schema = "
|
227
|
-
type A implements B, C {
|
228
|
-
a: String
|
229
|
-
}
|
230
|
-
"
|
231
|
-
|
232
|
-
document = parse(schema)
|
233
|
-
|
234
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
235
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
236
|
-
assert_equal [2, 36], document.definitions[0].interfaces[1].position
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
QUERY_STRING = %|
|
242
|
-
query getStuff($someVar: Int = 1, $anotherVar: [String!] ) @skip(if: false) {
|
243
|
-
myField: someField(someArg: $someVar, ok: 1.4) @skip(if: $anotherVar) @thing(or: "Whatever")
|
244
|
-
|
245
|
-
anotherField(someArg: [1,2,3]) {
|
246
|
-
nestedField
|
247
|
-
... moreNestedFields @skip(if: true)
|
248
|
-
}
|
249
|
-
|
250
|
-
... on OtherType @include(unless: false){
|
251
|
-
field(arg: [{key: "value", anotherKey: 0.9, anotherAnotherKey: WHATEVER}])
|
252
|
-
anotherField
|
253
|
-
}
|
254
|
-
|
255
|
-
... {
|
256
|
-
id
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
fragment moreNestedFields on NestedType @or(something: "ok") {
|
261
|
-
anotherNestedField @enum(directive: true)
|
262
|
-
}
|
263
|
-
|
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|