graphql 1.7.13 → 1.7.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/argument.rb +1 -0
- data/lib/graphql/base_type.rb +7 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +110 -0
- data/lib/graphql/directive.rb +1 -0
- data/lib/graphql/enum_type.rb +2 -0
- data/lib/graphql/execution/multiplex.rb +1 -1
- data/lib/graphql/field.rb +2 -0
- data/lib/graphql/language/document_from_schema_definition.rb +1 -1
- data/lib/graphql/language/lexer.rb +65 -51
- data/lib/graphql/language/lexer.rl +2 -0
- data/lib/graphql/language/nodes.rb +118 -71
- data/lib/graphql/language/parser.rb +701 -654
- data/lib/graphql/language/parser.y +14 -8
- data/lib/graphql/language/printer.rb +2 -2
- data/lib/graphql/object_type.rb +0 -5
- data/lib/graphql/relay/relation_connection.rb +1 -1
- data/lib/graphql/schema.rb +1 -0
- data/lib/graphql/schema/build_from_definition.rb +60 -18
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +1 -1
- data/lib/graphql/unresolved_type_error.rb +3 -2
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/base_type_spec.rb +22 -0
- data/spec/graphql/enum_type_spec.rb +18 -5
- data/spec/graphql/execution/multiplex_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +13 -0
- data/spec/graphql/language/nodes_spec.rb +0 -12
- data/spec/graphql/language/printer_spec.rb +1 -1
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
- data/spec/graphql/query_spec.rb +26 -0
- data/spec/graphql/relay/relation_connection_spec.rb +7 -1
- data/spec/graphql/schema/build_from_definition_spec.rb +59 -0
- data/spec/graphql/schema/printer_spec.rb +34 -0
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
- metadata +2 -2
data/spec/graphql/query_spec.rb
CHANGED
@@ -253,6 +253,32 @@ describe GraphQL::Query do
|
|
253
253
|
assert_equal [nil], Instrumenter::ERROR_LOG
|
254
254
|
end
|
255
255
|
end
|
256
|
+
|
257
|
+
describe "when an error propagated through execution" do
|
258
|
+
module ExtensionsInstrumenter
|
259
|
+
LOG = []
|
260
|
+
def self.before_query(q); end;
|
261
|
+
|
262
|
+
def self.after_query(q)
|
263
|
+
q.result["extensions"] = { "a" => 1 }
|
264
|
+
LOG << :ok
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
let(:schema) {
|
269
|
+
Dummy::Schema.redefine {
|
270
|
+
instrument(:query, ExtensionsInstrumenter)
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
it "can add to extensions" do
|
275
|
+
ExtensionsInstrumenter::LOG.clear
|
276
|
+
assert_raises(RuntimeError) do
|
277
|
+
schema.execute "{ error }"
|
278
|
+
end
|
279
|
+
assert_equal [:ok], ExtensionsInstrumenter::LOG
|
280
|
+
end
|
281
|
+
end
|
256
282
|
end
|
257
283
|
|
258
284
|
it "uses root_value as the object for the root type" do
|
@@ -117,6 +117,13 @@ describe GraphQL::Relay::RelationConnection do
|
|
117
117
|
assert_equal true, get_page_info(result)["hasNextPage"]
|
118
118
|
assert_equal true, get_page_info(result)["hasPreviousPage"]
|
119
119
|
|
120
|
+
last_cursor = get_last_cursor(result)
|
121
|
+
result = with_bidirectional_pagination {
|
122
|
+
star_wars_query(query_string, "last" => 1, "before" => last_cursor)
|
123
|
+
}
|
124
|
+
assert_equal true, get_page_info(result)["hasNextPage"]
|
125
|
+
assert_equal false, get_page_info(result)["hasPreviousPage"]
|
126
|
+
|
120
127
|
result = star_wars_query(query_string, "first" => 100)
|
121
128
|
last_cursor = get_last_cursor(result)
|
122
129
|
|
@@ -129,7 +136,6 @@ describe GraphQL::Relay::RelationConnection do
|
|
129
136
|
}
|
130
137
|
assert_equal true, get_page_info(result)["hasNextPage"]
|
131
138
|
assert_equal true, get_page_info(result)["hasPreviousPage"]
|
132
|
-
|
133
139
|
end
|
134
140
|
|
135
141
|
it 'slices the result' do
|
@@ -612,6 +612,65 @@ type Query {
|
|
612
612
|
|
613
613
|
build_schema_and_compare_output(schema.chop)
|
614
614
|
end
|
615
|
+
|
616
|
+
it "tracks original AST node" do
|
617
|
+
schema_definition = <<-GRAPHQL
|
618
|
+
schema {
|
619
|
+
query: Query
|
620
|
+
}
|
621
|
+
|
622
|
+
enum Enum {
|
623
|
+
VALUE
|
624
|
+
}
|
625
|
+
|
626
|
+
type Query {
|
627
|
+
field(argument: String): String
|
628
|
+
deprecatedField(argument: String): String @deprecated(reason: "Test")
|
629
|
+
}
|
630
|
+
|
631
|
+
interface Interface {
|
632
|
+
field(argument: String): String
|
633
|
+
}
|
634
|
+
|
635
|
+
union Union = Query
|
636
|
+
|
637
|
+
scalar Scalar
|
638
|
+
|
639
|
+
input Input {
|
640
|
+
argument: String
|
641
|
+
}
|
642
|
+
|
643
|
+
directive @Directive (
|
644
|
+
# Argument
|
645
|
+
argument: String
|
646
|
+
) on SCHEMA
|
647
|
+
|
648
|
+
type Type implements Interface {
|
649
|
+
field(argument: String): String
|
650
|
+
}
|
651
|
+
GRAPHQL
|
652
|
+
|
653
|
+
schema = GraphQL::Schema.from_definition(schema_definition)
|
654
|
+
|
655
|
+
assert_equal [1, 1], schema.ast_node.position
|
656
|
+
assert_equal [5, 1], schema.types["Enum"].ast_node.position
|
657
|
+
assert_equal [6, 3], schema.types["Enum"].values["VALUE"].ast_node.position
|
658
|
+
assert_equal [9, 1], schema.types["Query"].ast_node.position
|
659
|
+
assert_equal [10, 3], schema.types["Query"].fields["field"].ast_node.position
|
660
|
+
assert_equal [10, 9], schema.types["Query"].fields["field"].arguments["argument"].ast_node.position
|
661
|
+
assert_equal [11, 45], schema.types["Query"].fields["deprecatedField"].ast_node.directives[0].position
|
662
|
+
assert_equal [11, 57], schema.types["Query"].fields["deprecatedField"].ast_node.directives[0].arguments[0].position
|
663
|
+
assert_equal [14, 1], schema.types["Interface"].ast_node.position
|
664
|
+
assert_equal [15, 3], schema.types["Interface"].fields["field"].ast_node.position
|
665
|
+
assert_equal [15, 9], schema.types["Interface"].fields["field"].arguments["argument"].ast_node.position
|
666
|
+
assert_equal [18, 1], schema.types["Union"].ast_node.position
|
667
|
+
assert_equal [20, 1], schema.types["Scalar"].ast_node.position
|
668
|
+
assert_equal [22, 1], schema.types["Input"].ast_node.position
|
669
|
+
assert_equal [22, 1], schema.types["Input"].arguments["argument"].ast_node.position
|
670
|
+
assert_equal [26, 1], schema.directives["Directive"].ast_node.position
|
671
|
+
assert_equal [28, 3], schema.directives["Directive"].arguments["argument"].ast_node.position
|
672
|
+
assert_equal [31, 22], schema.types["Type"].ast_node.interfaces[0].position
|
673
|
+
end
|
615
674
|
end
|
616
675
|
|
617
676
|
describe 'Failures' do
|
@@ -610,6 +610,40 @@ type Post {
|
|
610
610
|
SCHEMA
|
611
611
|
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(schema.types['Post'])
|
612
612
|
end
|
613
|
+
|
614
|
+
it "can print arguments that use non-standard Ruby objects as default values" do
|
615
|
+
backing_object = Struct.new(:value)
|
616
|
+
|
617
|
+
scalar_type = GraphQL::ScalarType.define do
|
618
|
+
name "SomeType"
|
619
|
+
coerce_input ->(value, ctx) { backing_object.new(value) }
|
620
|
+
coerce_result ->(obj, ctx) { obj.value }
|
621
|
+
end
|
622
|
+
|
623
|
+
query_root = GraphQL::ObjectType.define do
|
624
|
+
name "Query"
|
625
|
+
description "The query root of this schema"
|
626
|
+
|
627
|
+
field :example do
|
628
|
+
type scalar_type
|
629
|
+
argument :input, scalar_type, default_value: backing_object.new("Howdy")
|
630
|
+
resolve ->(obj, args, ctx) { args[:input] }
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
schema = GraphQL::Schema.define do
|
635
|
+
query query_root
|
636
|
+
end
|
637
|
+
|
638
|
+
expected = <<SCHEMA
|
639
|
+
# The query root of this schema
|
640
|
+
type Query {
|
641
|
+
example(input: SomeType = "Howdy"): SomeType
|
642
|
+
}
|
643
|
+
SCHEMA
|
644
|
+
|
645
|
+
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(query_root)
|
646
|
+
end
|
613
647
|
end
|
614
648
|
|
615
649
|
describe "#print_directive" do
|
@@ -515,7 +515,7 @@ describe GraphQL::StaticValidation::FieldsWillMerge do
|
|
515
515
|
scalar: String!
|
516
516
|
}
|
517
517
|
|
518
|
-
type NonNullStringBox1Impl implements SomeBox
|
518
|
+
type NonNullStringBox1Impl implements SomeBox & NonNullStringBox1 {
|
519
519
|
scalar: String!
|
520
520
|
unrelatedField: String
|
521
521
|
deepBox: SomeBox
|
@@ -525,7 +525,7 @@ describe GraphQL::StaticValidation::FieldsWillMerge do
|
|
525
525
|
scalar: String!
|
526
526
|
}
|
527
527
|
|
528
|
-
type NonNullStringBox2Impl implements SomeBox
|
528
|
+
type NonNullStringBox2Impl implements SomeBox & NonNullStringBox2 {
|
529
529
|
scalar: String!
|
530
530
|
unrelatedField: String
|
531
531
|
deepBox: SomeBox
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|