graphql 1.7.14 → 1.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +1 -6
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/graphql.rb +2 -0
- data/lib/graphql/argument.rb +0 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +18 -16
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -117
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -14
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +28 -0
- data/lib/graphql/directive.rb +0 -1
- data/lib/graphql/enum_type.rb +1 -3
- data/lib/graphql/execution.rb +0 -1
- data/lib/graphql/execution/multiplex.rb +29 -12
- data/lib/graphql/field.rb +5 -20
- data/lib/graphql/function.rb +12 -0
- data/lib/graphql/input_object_type.rb +1 -3
- data/lib/graphql/internal_representation/node.rb +14 -26
- data/lib/graphql/internal_representation/visit.rb +6 -3
- data/lib/graphql/introspection/arguments_field.rb +0 -1
- data/lib/graphql/introspection/enum_values_field.rb +0 -1
- data/lib/graphql/introspection/fields_field.rb +0 -1
- data/lib/graphql/introspection/input_fields_field.rb +0 -1
- data/lib/graphql/introspection/interfaces_field.rb +0 -1
- data/lib/graphql/introspection/of_type_field.rb +0 -1
- data/lib/graphql/introspection/possible_types_field.rb +0 -1
- data/lib/graphql/introspection/schema_field.rb +0 -1
- data/lib/graphql/introspection/type_by_name_field.rb +0 -1
- data/lib/graphql/introspection/typename_field.rb +0 -1
- data/lib/graphql/language.rb +0 -3
- data/lib/graphql/language/generation.rb +182 -3
- data/lib/graphql/language/lexer.rb +69 -144
- data/lib/graphql/language/lexer.rl +4 -15
- data/lib/graphql/language/nodes.rb +76 -136
- data/lib/graphql/language/parser.rb +621 -668
- data/lib/graphql/language/parser.y +11 -17
- data/lib/graphql/language/token.rb +3 -10
- data/lib/graphql/object_type.rb +6 -1
- data/lib/graphql/query.rb +13 -8
- data/lib/graphql/query/arguments.rb +33 -48
- data/lib/graphql/query/context.rb +1 -0
- data/lib/graphql/query/literal_input.rb +1 -4
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +19 -14
- data/lib/graphql/schema.rb +219 -12
- data/lib/graphql/schema/argument.rb +33 -0
- data/lib/graphql/schema/build_from_definition.rb +18 -64
- data/lib/graphql/schema/enum.rb +76 -0
- data/lib/graphql/schema/field.rb +127 -0
- data/lib/graphql/schema/field/dynamic_resolve.rb +63 -0
- data/lib/graphql/schema/field/unwrapped_resolve.rb +20 -0
- data/lib/graphql/schema/input_object.rb +61 -0
- data/lib/graphql/schema/interface.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member.rb +97 -0
- data/lib/graphql/schema/member/build_type.rb +106 -0
- data/lib/graphql/schema/member/has_fields.rb +56 -0
- data/lib/graphql/schema/member/instrumentation.rb +113 -0
- data/lib/graphql/schema/member/list_type_proxy.rb +21 -0
- data/lib/graphql/schema/member/non_null_type_proxy.rb +21 -0
- data/lib/graphql/schema/object.rb +65 -0
- data/lib/graphql/schema/printer.rb +266 -33
- data/lib/graphql/schema/scalar.rb +25 -0
- data/lib/graphql/schema/traversal.rb +26 -17
- data/lib/graphql/schema/union.rb +48 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -15
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -11
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -7
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/tracing/platform_tracing.rb +7 -20
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -3
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/dummy/app/channels/graphql_channel.rb +1 -22
- data/spec/dummy/log/development.log +0 -239
- data/spec/dummy/log/test.log +0 -204
- data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -4
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/generators/graphql/function_generator_spec.rb +0 -26
- data/spec/generators/graphql/loader_generator_spec.rb +0 -24
- data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
- data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
- data/spec/graphql/backtrace_spec.rb +0 -10
- data/spec/graphql/base_type_spec.rb +5 -19
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +1 -3
- data/spec/graphql/enum_type_spec.rb +5 -18
- data/spec/graphql/execution/execute_spec.rb +1 -1
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/float_type_spec.rb +2 -2
- data/spec/graphql/id_type_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +2 -15
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +0 -1
- data/spec/graphql/language/generation_spec.rb +186 -21
- data/spec/graphql/language/lexer_spec.rb +1 -21
- data/spec/graphql/language/nodes_spec.rb +12 -21
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/query/arguments_spec.rb +15 -37
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
- data/spec/graphql/query/variables_spec.rb +1 -1
- data/spec/graphql/query_spec.rb +5 -31
- data/spec/graphql/rake_task_spec.rb +1 -3
- data/spec/graphql/relay/base_connection_spec.rb +1 -1
- data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
- data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
- data/spec/graphql/relay/connection_type_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +3 -3
- data/spec/graphql/relay/relation_connection_spec.rb +1 -65
- data/spec/graphql/schema/build_from_definition_spec.rb +4 -86
- data/spec/graphql/schema/enum_spec.rb +60 -0
- data/spec/graphql/schema/field_spec.rb +14 -0
- data/spec/graphql/schema/input_object_spec.rb +43 -0
- data/spec/graphql/schema/interface_spec.rb +98 -0
- data/spec/graphql/schema/object_spec.rb +119 -0
- data/spec/graphql/schema/printer_spec.rb +15 -92
- data/spec/graphql/schema/scalar_spec.rb +40 -0
- data/spec/graphql/schema/union_spec.rb +35 -0
- data/spec/graphql/schema/validation_spec.rb +1 -1
- data/spec/graphql/schema/warden_spec.rb +11 -11
- data/spec/graphql/schema_spec.rb +25 -23
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +2 -10
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
- data/spec/graphql/string_type_spec.rb +3 -3
- data/spec/graphql/subscriptions_spec.rb +1 -1
- data/spec/graphql/tracing/platform_tracing_spec.rb +1 -60
- data/spec/support/dummy/schema.rb +25 -39
- data/spec/support/jazz.rb +334 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/star_wars/data.rb +7 -6
- data/spec/support/star_wars/schema.rb +109 -142
- metadata +39 -33
- data/lib/graphql/execution/instrumentation.rb +0 -82
- data/lib/graphql/language/block_string.rb +0 -47
- data/lib/graphql/language/document_from_schema_definition.rb +0 -277
- data/lib/graphql/language/printer.rb +0 -351
- data/lib/graphql/tracing/data_dog_tracing.rb +0 -49
- data/spec/graphql/execution/instrumentation_spec.rb +0 -165
- data/spec/graphql/language/block_string_spec.rb +0 -70
- data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
- data/spec/graphql/language/printer_spec.rb +0 -203
@@ -1,203 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Language::Printer do
|
5
|
-
let(:document) { GraphQL::Language::Parser.parse(query_string) }
|
6
|
-
let(:query_string) {%|
|
7
|
-
query getStuff($someVar: Int = 1, $anotherVar: [String!], $skipNested: Boolean! = false) @skip(if: false) {
|
8
|
-
myField: someField(someArg: $someVar, ok: 1.4) @skip(if: $anotherVar) @thing(or: "Whatever")
|
9
|
-
anotherField(someArg: [1, 2, 3]) {
|
10
|
-
nestedField
|
11
|
-
...moreNestedFields @skip(if: $skipNested)
|
12
|
-
}
|
13
|
-
... on OtherType @include(unless: false) {
|
14
|
-
field(arg: [{key: "value", anotherKey: 0.9, anotherAnotherKey: WHATEVER}])
|
15
|
-
anotherField
|
16
|
-
}
|
17
|
-
... {
|
18
|
-
id
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
fragment moreNestedFields on NestedType @or(something: "ok") {
|
23
|
-
anotherNestedField
|
24
|
-
}
|
25
|
-
|}
|
26
|
-
|
27
|
-
let(:printer) { GraphQL::Language::Printer.new }
|
28
|
-
|
29
|
-
describe "#print" do
|
30
|
-
it "prints the query string" do
|
31
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "inputs" do
|
35
|
-
let(:query_string) {%|
|
36
|
-
query {
|
37
|
-
field(null_value: null, null_in_array: [1, null, 3], int: 3, float: 4.7e-24, bool: false, string: "☀︎🏆\\n escaped \\" unicode ¶ /", enum: ENUM_NAME, array: [7, 8, 9], object: {a: [1, 2, 3], b: {c: "4"}}, unicode_bom: "\xef\xbb\xbfquery")
|
38
|
-
}
|
39
|
-
|}
|
40
|
-
|
41
|
-
it "prints the query string" do
|
42
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "schema" do
|
47
|
-
describe "schema with convention names for root types" do
|
48
|
-
let(:query_string) {<<-schema
|
49
|
-
schema {
|
50
|
-
query: Query
|
51
|
-
mutation: Mutation
|
52
|
-
subscription: Subscription
|
53
|
-
}
|
54
|
-
schema
|
55
|
-
}
|
56
|
-
|
57
|
-
it 'omits schema definition' do
|
58
|
-
refute printer.print(document) =~ /schema/
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "schema with custom query root name" do
|
63
|
-
let(:query_string) {<<-schema
|
64
|
-
schema {
|
65
|
-
query: MyQuery
|
66
|
-
mutation: Mutation
|
67
|
-
subscription: Subscription
|
68
|
-
}
|
69
|
-
schema
|
70
|
-
}
|
71
|
-
|
72
|
-
it 'includes schema definition' do
|
73
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "schema with custom mutation root name" do
|
78
|
-
let(:query_string) {<<-schema
|
79
|
-
schema {
|
80
|
-
query: Query
|
81
|
-
mutation: MyMutation
|
82
|
-
subscription: Subscription
|
83
|
-
}
|
84
|
-
schema
|
85
|
-
}
|
86
|
-
|
87
|
-
it 'includes schema definition' do
|
88
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "schema with custom subscription root name" do
|
93
|
-
let(:query_string) {<<-schema
|
94
|
-
schema {
|
95
|
-
query: Query
|
96
|
-
mutation: Mutation
|
97
|
-
subscription: MySubscription
|
98
|
-
}
|
99
|
-
schema
|
100
|
-
}
|
101
|
-
|
102
|
-
it 'includes schema definition' do
|
103
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "full featured schema" do
|
108
|
-
# Based on: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql
|
109
|
-
let(:query_string) {<<-schema
|
110
|
-
schema {
|
111
|
-
query: QueryType
|
112
|
-
mutation: MutationType
|
113
|
-
}
|
114
|
-
|
115
|
-
# Union description
|
116
|
-
union AnnotatedUnion @onUnion = A | B
|
117
|
-
|
118
|
-
type Foo implements Bar & AnnotatedInterface {
|
119
|
-
one: Type
|
120
|
-
two(argument: InputType!): Type
|
121
|
-
three(argument: InputType, other: String): Int
|
122
|
-
four(argument: String = "string"): String
|
123
|
-
five(argument: [String] = ["string", "string"]): String
|
124
|
-
six(argument: InputType = {key: "value"}): Type
|
125
|
-
seven(argument: String = null): Type
|
126
|
-
}
|
127
|
-
|
128
|
-
# Scalar description
|
129
|
-
scalar CustomScalar
|
130
|
-
|
131
|
-
type AnnotatedObject implements Bar @onObject(arg: "value") {
|
132
|
-
annotatedField(arg: Type = "default" @onArg): Type @onField
|
133
|
-
}
|
134
|
-
|
135
|
-
interface Bar {
|
136
|
-
one: Type
|
137
|
-
four(argument: String = "string"): String
|
138
|
-
}
|
139
|
-
|
140
|
-
# Enum description
|
141
|
-
enum Site {
|
142
|
-
# Enum value description
|
143
|
-
DESKTOP
|
144
|
-
MOBILE
|
145
|
-
}
|
146
|
-
|
147
|
-
interface AnnotatedInterface @onInterface {
|
148
|
-
annotatedField(arg: Type @onArg): Type @onField
|
149
|
-
}
|
150
|
-
|
151
|
-
union Feed = Story | Article | Advert
|
152
|
-
|
153
|
-
# Input description
|
154
|
-
input InputType {
|
155
|
-
key: String!
|
156
|
-
answer: Int = 42
|
157
|
-
}
|
158
|
-
|
159
|
-
union AnnotatedUnion @onUnion = A | B
|
160
|
-
|
161
|
-
scalar CustomScalar
|
162
|
-
|
163
|
-
# Directive description
|
164
|
-
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
165
|
-
|
166
|
-
scalar AnnotatedScalar @onScalar
|
167
|
-
|
168
|
-
enum Site {
|
169
|
-
DESKTOP
|
170
|
-
MOBILE
|
171
|
-
}
|
172
|
-
|
173
|
-
enum AnnotatedEnum @onEnum {
|
174
|
-
ANNOTATED_VALUE @onEnumValue
|
175
|
-
OTHER_VALUE
|
176
|
-
}
|
177
|
-
|
178
|
-
input InputType {
|
179
|
-
key: String!
|
180
|
-
answer: Int = 42
|
181
|
-
}
|
182
|
-
|
183
|
-
input AnnotatedInput @onInputObjectType {
|
184
|
-
annotatedField: Type @onField
|
185
|
-
}
|
186
|
-
|
187
|
-
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
188
|
-
|
189
|
-
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
190
|
-
schema
|
191
|
-
}
|
192
|
-
|
193
|
-
it "generate" do
|
194
|
-
assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
|
195
|
-
end
|
196
|
-
|
197
|
-
it "doesn't mutate the document" do
|
198
|
-
assert_equal printer.print(document), printer.print(document)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|