Skip to content

Commit e71732f

Browse files
committed
Update NewRelicTrace spec
1 parent c068062 commit e71732f

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

spec/graphql/tracing/new_relic_trace_spec.rb

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ class Other < GraphQL::Schema::Object
3131
def self.authorized?(obj, ctx)
3232
ctx[:lazy] ? -> { true } : true
3333
end
34-
field :name, String
34+
field :name, String, resolve_batch: :name_field
35+
36+
def self.name_field(objects, context)
37+
context.dataload_all(EchoSource, Array.new(objects.size, "name"))
38+
end
3539

3640
def name
3741
dataload(EchoSource, "name")
@@ -41,21 +45,45 @@ def name
4145
class Query < GraphQL::Schema::Object
4246
include GraphQL::Types::Relay::HasNodeField
4347

44-
field :int, Integer, null: false
48+
field :int, Integer, null: false, resolve_static: true
4549

46-
def int
50+
def self.int(context)
4751
1
4852
end
4953

50-
field :other, Other
54+
def int
55+
self.class.int(context)
56+
end
57+
58+
field :other, Other, resolve_batch: true
59+
60+
def self.other(objects, context)
61+
context.dataload_all(OtherSource, Array.new(objects.size, :other))
62+
end
5163

5264
def other
5365
dataloader.with(OtherSource).load(:other)
5466
end
5567

56-
field :nameable, Nameable, fallback_value: :nameable
68+
field :nameable, Nameable, resolve_static: true
5769

58-
field :lazy_nameable, Nameable, fallback_value: -> { :nameable }
70+
def self.nameable(_ctx)
71+
:nameable
72+
end
73+
74+
def nameable
75+
self.class.nameable(context)
76+
end
77+
78+
field :lazy_nameable, Nameable, resolve_static: true
79+
80+
def self.lazy_nameable(context)
81+
-> { :nameable }
82+
end
83+
84+
def lazy_nameable
85+
self.class.lazy_nameable(context)
86+
end
5987
end
6088

6189
class SchemaWithoutTransactionName < GraphQL::Schema
@@ -153,8 +181,8 @@ class SchemaWithoutAuthorizedOrResolveType < GraphQL::Schema
153181
"GraphQL/validate",
154182
"FINISH GraphQL/analyze",
155183

156-
"GraphQL/Authorized/Query",
157-
"FINISH GraphQL/Authorized/Query",
184+
# Exec-next doesn't run no-op authorization:
185+
*(TESTING_EXEC_NEXT ? [] : ["GraphQL/Authorized/Query", "FINISH GraphQL/Authorized/Query"]),
158186
"GraphQL/Query/other",
159187
"FINISH GraphQL/Query/other",
160188
# Here's the source run:
@@ -219,8 +247,8 @@ class SchemaWithoutAuthorizedOrResolveType < GraphQL::Schema
219247
"GraphQL/analyze",
220248
"GraphQL/validate",
221249
"FINISH GraphQL/analyze",
222-
"GraphQL/Authorized/Query",
223-
"FINISH GraphQL/Authorized/Query",
250+
# Exec-next doesn't run no-op authorization:
251+
*(TESTING_EXEC_NEXT ? [] : ["GraphQL/Authorized/Query", "FINISH GraphQL/Authorized/Query"]),
224252
# Eager:
225253
"GraphQL/Query/lazyNameable",
226254
"FINISH GraphQL/Query/lazyNameable",

0 commit comments

Comments
 (0)