graphql 2.0.6 → 2.0.9
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/generators/graphql/relay.rb +3 -17
- data/lib/graphql/analysis/ast/field_usage.rb +3 -1
- data/lib/graphql/execution/interpreter/resolve.rb +7 -0
- data/lib/graphql/execution/interpreter/runtime.rb +23 -3
- data/lib/graphql/execution/lazy.rb +0 -1
- data/lib/graphql/language/parser.rb +338 -327
- data/lib/graphql/language/parser.y +12 -8
- data/lib/graphql/language/printer.rb +9 -5
- data/lib/graphql/pagination/connection.rb +31 -4
- data/lib/graphql/pagination/connections.rb +1 -0
- data/lib/graphql/schema/field/connection_extension.rb +4 -0
- data/lib/graphql/schema/field.rb +54 -14
- data/lib/graphql/schema/resolver.rb +21 -0
- data/lib/graphql/schema/warden.rb +6 -2
- data/lib/graphql/schema.rb +24 -8
- data/lib/graphql/subscriptions.rb +15 -3
- data/lib/graphql/tracing/data_dog_tracing.rb +16 -1
- data/lib/graphql/tracing/opentelemetry_tracing.rb +101 -0
- data/lib/graphql/tracing/platform_tracing.rb +8 -4
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/types/iso_8601_date_time.rb +3 -0
- data/lib/graphql/types/relay/base_connection.rb +16 -6
- data/lib/graphql/version.rb +1 -1
- metadata +3 -3
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
@@ -10,6 +10,10 @@ module GraphQL
|
|
10
10
|
class PlatformTracing
|
11
11
|
class << self
|
12
12
|
attr_accessor :platform_keys
|
13
|
+
|
14
|
+
def inherited(child_class)
|
15
|
+
child_class.platform_keys = self.platform_keys
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def initialize(options = {})
|
@@ -41,7 +45,7 @@ module GraphQL
|
|
41
45
|
|
42
46
|
platform_key = if trace_field
|
43
47
|
context = data.fetch(:query).context
|
44
|
-
cached_platform_key(context, field) { platform_field_key(data[:owner], field) }
|
48
|
+
cached_platform_key(context, field, :field) { platform_field_key(data[:owner], field) }
|
45
49
|
else
|
46
50
|
nil
|
47
51
|
end
|
@@ -57,14 +61,14 @@ module GraphQL
|
|
57
61
|
when "authorized", "authorized_lazy"
|
58
62
|
type = data.fetch(:type)
|
59
63
|
context = data.fetch(:context)
|
60
|
-
platform_key = cached_platform_key(context, type) { platform_authorized_key(type) }
|
64
|
+
platform_key = cached_platform_key(context, type, :authorized) { platform_authorized_key(type) }
|
61
65
|
platform_trace(platform_key, key, data) do
|
62
66
|
yield
|
63
67
|
end
|
64
68
|
when "resolve_type", "resolve_type_lazy"
|
65
69
|
type = data.fetch(:type)
|
66
70
|
context = data.fetch(:context)
|
67
|
-
platform_key = cached_platform_key(context, type) { platform_resolve_type_key(type) }
|
71
|
+
platform_key = cached_platform_key(context, type, :resolve_type) { platform_resolve_type_key(type) }
|
68
72
|
platform_trace(platform_key, key, data) do
|
69
73
|
yield
|
70
74
|
end
|
@@ -112,7 +116,7 @@ module GraphQL
|
|
112
116
|
# If the key isn't present, the given block is called and the result is cached for `key`.
|
113
117
|
#
|
114
118
|
# @return [String]
|
115
|
-
def cached_platform_key(ctx, key)
|
119
|
+
def cached_platform_key(ctx, key, trace_phase)
|
116
120
|
cache = ctx.namespace(self.class)[:platform_key_cache] ||= {}
|
117
121
|
cache.fetch(key) { cache[key] = yield }
|
118
122
|
end
|
data/lib/graphql/tracing.rb
CHANGED
@@ -8,6 +8,7 @@ require "graphql/tracing/new_relic_tracing"
|
|
8
8
|
require "graphql/tracing/scout_tracing"
|
9
9
|
require "graphql/tracing/statsd_tracing"
|
10
10
|
require "graphql/tracing/prometheus_tracing"
|
11
|
+
require "graphql/tracing/opentelemetry_tracing"
|
11
12
|
|
12
13
|
if defined?(PrometheusExporter::Server)
|
13
14
|
require "graphql/tracing/prometheus_tracing/graphql_collector"
|
@@ -60,6 +60,9 @@ module GraphQL
|
|
60
60
|
# But without this, it would zero out given any time part of `str_value` (hours and/or minutes)
|
61
61
|
if dt.iso8601.start_with?(str_value)
|
62
62
|
dt
|
63
|
+
elsif str_value.length == 8 && str_value.match?(/\A\d{8}\Z/)
|
64
|
+
# Allow dates that are missing the "-". eg. "20220404"
|
65
|
+
dt
|
63
66
|
else
|
64
67
|
nil
|
65
68
|
end
|
@@ -10,6 +10,8 @@ module GraphQL
|
|
10
10
|
# so you can extend your own `BaseObject` instead of `GraphQL::Schema::Object`.
|
11
11
|
#
|
12
12
|
# @example Implementation a connection and edge
|
13
|
+
# class BaseObject < GraphQL::Schema::Object; end
|
14
|
+
#
|
13
15
|
# # Given some object in your app ...
|
14
16
|
# class Types::Post < BaseObject
|
15
17
|
# end
|
@@ -20,14 +22,22 @@ module GraphQL
|
|
20
22
|
#
|
21
23
|
# # Then extend them for the object in your app
|
22
24
|
# class Types::PostEdge < Types::BaseEdge
|
23
|
-
# node_type
|
25
|
+
# node_type Types::Post
|
24
26
|
# end
|
27
|
+
#
|
25
28
|
# class Types::PostConnection < Types::BaseConnection
|
26
|
-
# edge_type
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
29
|
+
# edge_type Types::PostEdge,
|
30
|
+
# edges_nullable: true,
|
31
|
+
# edge_nullable: true,
|
32
|
+
# node_nullable: true,
|
33
|
+
# nodes_field: true
|
34
|
+
#
|
35
|
+
# # Alternatively, you can call the class methods followed by your edge type
|
36
|
+
# # edges_nullable true
|
37
|
+
# # edge_nullable true
|
38
|
+
# # nodes_nullable true
|
39
|
+
# # has_nodes_field true
|
40
|
+
# # edge_type Types::PostEdge
|
31
41
|
# end
|
32
42
|
#
|
33
43
|
# @see Relay::BaseEdge for edge types
|
data/lib/graphql/version.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.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: 2022-
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -314,7 +314,6 @@ files:
|
|
314
314
|
- lib/graphql/execution/interpreter/runtime.rb
|
315
315
|
- lib/graphql/execution/lazy.rb
|
316
316
|
- lib/graphql/execution/lazy/lazy_method_map.rb
|
317
|
-
- lib/graphql/execution/lazy/resolve.rb
|
318
317
|
- lib/graphql/execution/lookahead.rb
|
319
318
|
- lib/graphql/execution/multiplex.rb
|
320
319
|
- lib/graphql/execution_error.rb
|
@@ -539,6 +538,7 @@ files:
|
|
539
538
|
- lib/graphql/tracing/data_dog_tracing.rb
|
540
539
|
- lib/graphql/tracing/new_relic_tracing.rb
|
541
540
|
- lib/graphql/tracing/notifications_tracing.rb
|
541
|
+
- lib/graphql/tracing/opentelemetry_tracing.rb
|
542
542
|
- lib/graphql/tracing/platform_tracing.rb
|
543
543
|
- lib/graphql/tracing/prometheus_tracing.rb
|
544
544
|
- lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
module Execution
|
4
|
-
class Lazy
|
5
|
-
# Helpers for dealing with data structures containing {Lazy} instances
|
6
|
-
# @api private
|
7
|
-
module Resolve
|
8
|
-
# Mutate `value`, replacing {Lazy} instances in place with their resolved values
|
9
|
-
# @return [void]
|
10
|
-
|
11
|
-
# This object can be passed like an array, but it doesn't allocate an
|
12
|
-
# array until it's used.
|
13
|
-
#
|
14
|
-
# There's one crucial difference: you have to _capture_ the result
|
15
|
-
# of `#<<`. (This _works_ with arrays but isn't required, since it has a side-effect.)
|
16
|
-
# @api private
|
17
|
-
module NullAccumulator
|
18
|
-
def self.<<(item)
|
19
|
-
[item]
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.empty?
|
23
|
-
true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.resolve(value)
|
28
|
-
lazies = resolve_in_place(value)
|
29
|
-
deep_sync(lazies)
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.resolve_in_place(value)
|
33
|
-
acc = each_lazy(NullAccumulator, value)
|
34
|
-
|
35
|
-
if acc.empty?
|
36
|
-
Lazy::NullResult
|
37
|
-
else
|
38
|
-
Lazy.new {
|
39
|
-
acc.each_with_index { |ctx, idx|
|
40
|
-
acc[idx] = ctx.value.value
|
41
|
-
}
|
42
|
-
resolve_in_place(acc)
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# If `value` is a collection,
|
48
|
-
# add any {Lazy} instances in the collection
|
49
|
-
# to `acc`
|
50
|
-
# @return [void]
|
51
|
-
def self.each_lazy(acc, value)
|
52
|
-
case value
|
53
|
-
when Hash
|
54
|
-
value.each do |key, field_result|
|
55
|
-
acc = each_lazy(acc, field_result)
|
56
|
-
end
|
57
|
-
when Array
|
58
|
-
value.each do |field_result|
|
59
|
-
acc = each_lazy(acc, field_result)
|
60
|
-
end
|
61
|
-
when Query::Context::SharedMethods
|
62
|
-
field_value = value.value
|
63
|
-
case field_value
|
64
|
-
when Lazy
|
65
|
-
acc = acc << value
|
66
|
-
when Enumerable # shortcut for Hash & Array
|
67
|
-
acc = each_lazy(acc, field_value)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
acc
|
72
|
-
end
|
73
|
-
|
74
|
-
# Traverse `val`, triggering resolution for each {Lazy}.
|
75
|
-
# These {Lazy}s are expected to mutate their owner data structures
|
76
|
-
# during resolution! (They're created with the `.then` calls in `resolve_in_place`).
|
77
|
-
# @return [void]
|
78
|
-
def self.deep_sync(val)
|
79
|
-
case val
|
80
|
-
when Lazy
|
81
|
-
deep_sync(val.value)
|
82
|
-
when Array
|
83
|
-
val.each { |v| deep_sync(v.value) }
|
84
|
-
when Hash
|
85
|
-
val.each { |k, v| deep_sync(v.value) }
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|