graphql 1.7.7 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/graphql/enum_type.rb +1 -1
- data/lib/graphql/field.rb +10 -1
- data/lib/graphql/input_object_type.rb +3 -1
- data/lib/graphql/introspection/arguments_field.rb +1 -0
- data/lib/graphql/introspection/enum_values_field.rb +1 -0
- data/lib/graphql/introspection/fields_field.rb +1 -0
- data/lib/graphql/introspection/input_fields_field.rb +1 -0
- data/lib/graphql/introspection/interfaces_field.rb +1 -0
- data/lib/graphql/introspection/of_type_field.rb +1 -0
- data/lib/graphql/introspection/possible_types_field.rb +1 -0
- data/lib/graphql/introspection/schema_field.rb +1 -0
- data/lib/graphql/introspection/type_by_name_field.rb +1 -0
- data/lib/graphql/introspection/typename_field.rb +1 -0
- data/lib/graphql/language.rb +1 -0
- data/lib/graphql/language/document_from_schema_definition.rb +129 -37
- data/lib/graphql/language/generation.rb +3 -182
- data/lib/graphql/language/nodes.rb +12 -2
- data/lib/graphql/language/parser.rb +63 -55
- data/lib/graphql/language/parser.y +2 -1
- data/lib/graphql/language/printer.rb +351 -0
- data/lib/graphql/object_type.rb +1 -1
- data/lib/graphql/query/arguments.rb +27 -9
- data/lib/graphql/query/literal_input.rb +4 -1
- data/lib/graphql/schema/printer.rb +33 -266
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/language/document_from_schema_definition_spec.rb +729 -296
- data/spec/graphql/language/generation_spec.rb +21 -186
- data/spec/graphql/language/nodes_spec.rb +21 -0
- data/spec/graphql/language/printer_spec.rb +203 -0
- data/spec/graphql/query/arguments_spec.rb +33 -11
- data/spec/graphql/schema/build_from_definition_spec.rb +13 -4
- data/spec/graphql/schema/printer_spec.rb +14 -14
- metadata +5 -2
@@ -16,14 +16,22 @@ describe GraphQL::Query::Arguments do
|
|
16
16
|
argument :c, !test_input_1, as: :inputObject
|
17
17
|
end
|
18
18
|
|
19
|
-
GraphQL::Query::Arguments.new(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
GraphQL::Query::Arguments.new(
|
20
|
+
{
|
21
|
+
a: 1,
|
22
|
+
b: 2,
|
23
|
+
c: GraphQL::Query::Arguments.new(
|
24
|
+
{
|
25
|
+
d: 3,
|
26
|
+
e: 4,
|
27
|
+
},
|
28
|
+
argument_definitions: test_input_1.arguments,
|
29
|
+
defaults_used: Set.new
|
30
|
+
),
|
31
|
+
},
|
32
|
+
argument_definitions: test_input_2.arguments,
|
33
|
+
defaults_used: Set.new
|
34
|
+
)
|
27
35
|
}
|
28
36
|
|
29
37
|
it "returns keys as strings, with aliases" do
|
@@ -73,7 +81,11 @@ describe GraphQL::Query::Arguments do
|
|
73
81
|
)
|
74
82
|
end
|
75
83
|
|
76
|
-
new_arguments = GraphQL::Query::Arguments.new(
|
84
|
+
new_arguments = GraphQL::Query::Arguments.new(
|
85
|
+
transformed_args,
|
86
|
+
argument_definitions: types,
|
87
|
+
defaults_used: Set.new
|
88
|
+
)
|
77
89
|
expected_hash = {
|
78
90
|
"A" => 1,
|
79
91
|
"B" => 2,
|
@@ -96,7 +108,8 @@ describe GraphQL::Query::Arguments do
|
|
96
108
|
it "wraps input objects, but not other hashes" do
|
97
109
|
args = GraphQL::Query::Arguments.new(
|
98
110
|
{a: 1, b: {a: 2}, c: {a: 3}},
|
99
|
-
argument_definitions: input_type.arguments
|
111
|
+
argument_definitions: input_type.arguments,
|
112
|
+
defaults_used: Set.new
|
100
113
|
)
|
101
114
|
assert_kind_of GraphQL::Query::Arguments, args["b"]
|
102
115
|
assert_instance_of Hash, args["c"]
|
@@ -198,6 +211,15 @@ describe GraphQL::Query::Arguments do
|
|
198
211
|
assert_equal({"a" => 1, "b" => 2}, last_args.to_h)
|
199
212
|
end
|
200
213
|
|
214
|
+
it "indicates when default argument values were applied" do
|
215
|
+
schema.execute("{ argTest(a: 1) }")
|
216
|
+
|
217
|
+
last_args = arg_values.last
|
218
|
+
|
219
|
+
assert_equal false, last_args.default_used?('a')
|
220
|
+
assert_equal true, last_args.default_used?('b')
|
221
|
+
end
|
222
|
+
|
201
223
|
it "works from variables" do
|
202
224
|
variables = { "arg" => { "a" => 1, "d" => nil } }
|
203
225
|
schema.execute("query ArgTest($arg: TestInput){ argTest(d: $arg) }", variables: variables)
|
@@ -306,7 +328,7 @@ describe GraphQL::Query::Arguments do
|
|
306
328
|
assert_nil input_object.arguments_class
|
307
329
|
|
308
330
|
GraphQL::Query::Arguments.construct_arguments_class(input_object)
|
309
|
-
args = input_object.arguments_class.new({foo: 3, bar: -90})
|
331
|
+
args = input_object.arguments_class.new({foo: 3, bar: -90}, Set.new)
|
310
332
|
|
311
333
|
assert_equal 3, args.foo
|
312
334
|
assert_equal -90, args.bar
|
@@ -308,7 +308,7 @@ schema {
|
|
308
308
|
}
|
309
309
|
|
310
310
|
type Hello {
|
311
|
-
str(
|
311
|
+
str(bool: Boolean, int: Int): String
|
312
312
|
}
|
313
313
|
SCHEMA
|
314
314
|
|
@@ -505,7 +505,7 @@ type HelloScalars {
|
|
505
505
|
}
|
506
506
|
|
507
507
|
type Mutation {
|
508
|
-
addHelloScalars(
|
508
|
+
addHelloScalars(bool: Boolean, int: Int, str: String): HelloScalars
|
509
509
|
}
|
510
510
|
SCHEMA
|
511
511
|
|
@@ -520,7 +520,7 @@ enum Color {
|
|
520
520
|
}
|
521
521
|
|
522
522
|
type Mutation {
|
523
|
-
hello(
|
523
|
+
hello(color: Color = RED, int: Int, nullDefault: Int = null, str: String): String
|
524
524
|
}
|
525
525
|
|
526
526
|
type Query {
|
@@ -545,7 +545,7 @@ type HelloScalars {
|
|
545
545
|
}
|
546
546
|
|
547
547
|
type Subscription {
|
548
|
-
subscribeHelloScalars(
|
548
|
+
subscribeHelloScalars(bool: Boolean, int: Int, str: String): HelloScalars
|
549
549
|
}
|
550
550
|
SCHEMA
|
551
551
|
|
@@ -603,6 +603,15 @@ type Query {
|
|
603
603
|
|
604
604
|
build_schema_and_compare_output(schema.chop)
|
605
605
|
end
|
606
|
+
|
607
|
+
it 'supports empty types' do
|
608
|
+
schema = <<-SCHEMA
|
609
|
+
type Query {
|
610
|
+
}
|
611
|
+
SCHEMA
|
612
|
+
|
613
|
+
build_schema_and_compare_output(schema.chop)
|
614
|
+
end
|
606
615
|
end
|
607
616
|
|
608
617
|
describe 'Failures' do
|
@@ -136,6 +136,14 @@ schema {
|
|
136
136
|
query: Root
|
137
137
|
}
|
138
138
|
|
139
|
+
# Marks an element of a GraphQL schema as no longer supported.
|
140
|
+
directive @deprecated(
|
141
|
+
# Explains why this element was deprecated, usually also including a suggestion
|
142
|
+
# for how to access supported similar data. Formatted in
|
143
|
+
# [Markdown](https://daringfireball.net/projects/markdown/).
|
144
|
+
reason: String = "No longer supported"
|
145
|
+
) on FIELD_DEFINITION | ENUM_VALUE
|
146
|
+
|
139
147
|
# Directs the executor to include this field or fragment only when the `if` argument is true.
|
140
148
|
directive @include(
|
141
149
|
# Included when true.
|
@@ -148,14 +156,6 @@ directive @skip(
|
|
148
156
|
if: Boolean!
|
149
157
|
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
150
158
|
|
151
|
-
# Marks an element of a GraphQL schema as no longer supported.
|
152
|
-
directive @deprecated(
|
153
|
-
# Explains why this element was deprecated, usually also including a suggestion
|
154
|
-
# for how to access supported similar data. Formatted in
|
155
|
-
# [Markdown](https://daringfireball.net/projects/markdown/).
|
156
|
-
reason: String = "No longer supported"
|
157
|
-
) on FIELD_DEFINITION | ENUM_VALUE
|
158
|
-
|
159
159
|
# A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
|
160
160
|
#
|
161
161
|
# In some cases, you need to provide options to alter GraphQL's execution behavior
|
@@ -345,7 +345,6 @@ schema {
|
|
345
345
|
subscription: Subscription
|
346
346
|
}
|
347
347
|
SCHEMA
|
348
|
-
|
349
348
|
assert_match expected, GraphQL::Schema::Printer.print_schema(custom_schema)
|
350
349
|
end
|
351
350
|
|
@@ -390,7 +389,7 @@ type Audio {
|
|
390
389
|
|
391
390
|
enum Choice {
|
392
391
|
BAR
|
393
|
-
BAZ @deprecated(reason: "Use
|
392
|
+
BAZ @deprecated(reason: "Use "BAR".")
|
394
393
|
FOO
|
395
394
|
WOZ @deprecated
|
396
395
|
}
|
@@ -439,7 +438,7 @@ interface Node {
|
|
439
438
|
type Post {
|
440
439
|
body: String!
|
441
440
|
comments: [Comment!]
|
442
|
-
comments_count: Int! @deprecated(reason: "Use
|
441
|
+
comments_count: Int! @deprecated(reason: "Use "comments".")
|
443
442
|
id: ID!
|
444
443
|
title: String!
|
445
444
|
}
|
@@ -489,7 +488,6 @@ enum Choice {
|
|
489
488
|
}
|
490
489
|
|
491
490
|
type Subscription {
|
492
|
-
|
493
491
|
}
|
494
492
|
|
495
493
|
input Varied {
|
@@ -509,7 +507,9 @@ SCHEMA
|
|
509
507
|
when GraphQL::Argument
|
510
508
|
member.name != "id"
|
511
509
|
else
|
512
|
-
member.deprecation_reason
|
510
|
+
if member.respond_to?(:deprecation_reason)
|
511
|
+
member.deprecation_reason.nil?
|
512
|
+
end
|
513
513
|
end
|
514
514
|
}
|
515
515
|
|
@@ -600,7 +600,7 @@ SCHEMA
|
|
600
600
|
type Post {
|
601
601
|
body: String!
|
602
602
|
comments: [Comment!]
|
603
|
-
comments_count: Int! @deprecated(reason:
|
603
|
+
comments_count: Int! @deprecated(reason: "Use "comments".")
|
604
604
|
id: ID!
|
605
605
|
title: String!
|
606
606
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -426,6 +426,7 @@ files:
|
|
426
426
|
- lib/graphql/language/nodes.rb
|
427
427
|
- lib/graphql/language/parser.rb
|
428
428
|
- lib/graphql/language/parser.y
|
429
|
+
- lib/graphql/language/printer.rb
|
429
430
|
- lib/graphql/language/token.rb
|
430
431
|
- lib/graphql/language/visitor.rb
|
431
432
|
- lib/graphql/list_type.rb
|
@@ -905,6 +906,7 @@ files:
|
|
905
906
|
- spec/graphql/language/lexer_spec.rb
|
906
907
|
- spec/graphql/language/nodes_spec.rb
|
907
908
|
- spec/graphql/language/parser_spec.rb
|
909
|
+
- spec/graphql/language/printer_spec.rb
|
908
910
|
- spec/graphql/language/visitor_spec.rb
|
909
911
|
- spec/graphql/list_type_spec.rb
|
910
912
|
- spec/graphql/non_null_type_spec.rb
|
@@ -1375,6 +1377,7 @@ test_files:
|
|
1375
1377
|
- spec/graphql/language/lexer_spec.rb
|
1376
1378
|
- spec/graphql/language/nodes_spec.rb
|
1377
1379
|
- spec/graphql/language/parser_spec.rb
|
1380
|
+
- spec/graphql/language/printer_spec.rb
|
1378
1381
|
- spec/graphql/language/visitor_spec.rb
|
1379
1382
|
- spec/graphql/list_type_spec.rb
|
1380
1383
|
- spec/graphql/non_null_type_spec.rb
|