graphql 1.9.8 → 1.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/language/nodes.rb +8 -1
- data/lib/graphql/schema.rb +4 -1
- data/lib/graphql/tracing/platform_tracing.rb +6 -3
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/schema_spec.rb +36 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d591b26a453b53597b0fdbd363cf87ff174835672d1922499ec24bf0a219a9a
|
4
|
+
data.tar.gz: aad2c15974f1f58cf03fbf620513b4f2de6e8ae26f615937523089e8a2a4b52d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9058ce614080bcaa58692aef2287c5b67d63f8ed6fb27462976343801dc9e573cbc9a0e7e54dc545698d442ac66b832aa8ddda1f79dd30703aaed66fddf7564
|
7
|
+
data.tar.gz: b42bfa78dd4c0e71a02efbfdc1ee26e8fe00e2db43849728a2775ff1db2e062bd4fb17d95808c692a82b3c73982a368610e163abb3b7dc938913ff622d79fc30
|
@@ -73,7 +73,11 @@ module GraphQL
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def to_query_string(printer: GraphQL::Language::Printer.new)
|
76
|
-
printer.
|
76
|
+
if printer.is_a?(GraphQL::Language::Printer)
|
77
|
+
@query_string ||= printer.print(self)
|
78
|
+
else
|
79
|
+
printer.print(self)
|
80
|
+
end
|
77
81
|
end
|
78
82
|
|
79
83
|
# This creates a copy of `self`, with `new_options` applied.
|
@@ -83,6 +87,9 @@ module GraphQL
|
|
83
87
|
copied_self = dup
|
84
88
|
new_options.each do |key, value|
|
85
89
|
copied_self.instance_variable_set(:"@#{key}", value)
|
90
|
+
if copied_self.instance_variable_defined?(:@query_string)
|
91
|
+
copied_self.instance_variable_set(:@query_string, nil)
|
92
|
+
end
|
86
93
|
end
|
87
94
|
copied_self
|
88
95
|
end
|
data/lib/graphql/schema.rb
CHANGED
@@ -85,7 +85,6 @@ module GraphQL
|
|
85
85
|
extend GraphQL::Schema::FindInheritedValue
|
86
86
|
|
87
87
|
accepts_definitions \
|
88
|
-
:query, :mutation, :subscription,
|
89
88
|
:query_execution_strategy, :mutation_execution_strategy, :subscription_execution_strategy,
|
90
89
|
:max_depth, :max_complexity, :default_max_page_size,
|
91
90
|
:orphan_types, :resolve_type, :type_error, :parse_error,
|
@@ -94,6 +93,10 @@ module GraphQL
|
|
94
93
|
:object_from_id, :id_from_object,
|
95
94
|
:default_mask,
|
96
95
|
:cursor_encoder,
|
96
|
+
# If these are given as classes, normalize them. Accept `nil` when building from string.
|
97
|
+
query: ->(schema, t) { schema.query = t.respond_to?(:graphql_definition) ? t.graphql_definition : t },
|
98
|
+
mutation: ->(schema, t) { schema.mutation = t.respond_to?(:graphql_definition) ? t.graphql_definition : t },
|
99
|
+
subscription: ->(schema, t) { schema.subscription = t.respond_to?(:graphql_definition) ? t.graphql_definition : t },
|
97
100
|
disable_introspection_entry_points: ->(schema) { schema.disable_introspection_entry_points = true },
|
98
101
|
directives: ->(schema, directives) { schema.directives = directives.reduce({}) { |m, d| m[d.name] = d; m } },
|
99
102
|
directive: ->(schema, directive) { schema.directives[directive.graphql_name] = directive },
|
@@ -21,6 +21,7 @@ module GraphQL
|
|
21
21
|
def trace(key, data)
|
22
22
|
case key
|
23
23
|
when "lex", "parse", "validate", "analyze_query", "analyze_multiplex", "execute_query", "execute_query_lazy", "execute_multiplex"
|
24
|
+
data.fetch(:query).context.namespace(self.class)[:platform_key_cache] = {} if key == "execute_query"
|
24
25
|
platform_key = @platform_keys.fetch(key)
|
25
26
|
platform_trace(platform_key, key, data) do
|
26
27
|
yield
|
@@ -32,9 +33,11 @@ module GraphQL
|
|
32
33
|
trace_field = true # implemented with instrumenter
|
33
34
|
else
|
34
35
|
field = data[:field]
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
platform_key_cache = data.fetch(:query).context.namespace(self.class).fetch(:platform_key_cache)
|
37
|
+
platform_key = platform_key_cache.fetch(field) do
|
38
|
+
platform_key_cache[field] = platform_field_key(data[:owner], field)
|
39
|
+
end
|
40
|
+
|
38
41
|
return_type = field.type.unwrap
|
39
42
|
# Handle LateBoundTypes, which don't have `#kind`
|
40
43
|
trace_field = if return_type.respond_to?(:kind) && (return_type.kind.scalar? || return_type.kind.enum?)
|
data/lib/graphql/version.rb
CHANGED
data/spec/graphql/schema_spec.rb
CHANGED
@@ -4,13 +4,13 @@ require "spec_helper"
|
|
4
4
|
describe GraphQL::Schema do
|
5
5
|
describe "inheritance" do
|
6
6
|
class DummyFeature1 < GraphQL::Schema::Directive::Feature
|
7
|
-
|
7
|
+
|
8
8
|
end
|
9
9
|
|
10
10
|
class DummyFeature2 < GraphQL::Schema::Directive::Feature
|
11
11
|
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
let(:base_schema) do
|
15
15
|
Class.new(GraphQL::Schema) do
|
16
16
|
query GraphQL::Schema::Object
|
@@ -132,4 +132,38 @@ describe GraphQL::Schema do
|
|
132
132
|
assert_equal 3, schema.middleware.steps.size
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
describe "when mixing define and class-based" do
|
137
|
+
module MixedSchema
|
138
|
+
class Query < GraphQL::Schema::Object
|
139
|
+
field :int, Int, null: false
|
140
|
+
end
|
141
|
+
|
142
|
+
class Mutation < GraphQL::Schema::Object
|
143
|
+
field :int, Int, null: false
|
144
|
+
end
|
145
|
+
|
146
|
+
class Subscription < GraphQL::Schema::Object
|
147
|
+
field :int, Int, null: false
|
148
|
+
end
|
149
|
+
|
150
|
+
Schema = GraphQL::Schema.define do
|
151
|
+
query(Query)
|
152
|
+
mutation(Mutation)
|
153
|
+
subscription(Subscription)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it "includes root types properly" do
|
158
|
+
res = MixedSchema::Schema.as_json
|
159
|
+
assert_equal "Query", res["data"]["__schema"]["queryType"]["name"]
|
160
|
+
assert_includes res["data"]["__schema"]["types"].map { |t| t["name"] }, "Query"
|
161
|
+
|
162
|
+
assert_equal "Mutation", res["data"]["__schema"]["mutationType"]["name"]
|
163
|
+
assert_includes res["data"]["__schema"]["types"].map { |t| t["name"] }, "Mutation"
|
164
|
+
|
165
|
+
assert_equal "Subscription", res["data"]["__schema"]["subscriptionType"]["name"]
|
166
|
+
assert_includes res["data"]["__schema"]["types"].map { |t| t["name"] }, "Subscription"
|
167
|
+
end
|
168
|
+
end
|
135
169
|
end
|
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.9.
|
4
|
+
version: 1.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|