11package graphql.execution.instrumentation.dataloader
22
3- import graphql.Directives
3+
44import graphql.GraphQL
55import graphql.execution.instrumentation.Instrumentation
66import graphql.schema.GraphQLSchema
77import org.dataloader.DataLoaderRegistry
88
9-
109class DataLoaderPerformanceData {
1110
1211 private final BatchCompareDataFetchers batchCompareDataFetchers;
@@ -23,7 +22,6 @@ class DataLoaderPerformanceData {
2322
2423 GraphQL setupGraphQL (Instrumentation instrumentation ) {
2524 GraphQLSchema schema = new BatchCompare (). buildDataLoaderSchema(batchCompareDataFetchers)
26- schema = schema. transform({ bldr -> bldr. additionalDirective(Directives.DeferDirective ) })
2725
2826 GraphQL . newGraphQL(schema)
2927 .instrumentation(instrumentation)
@@ -156,110 +154,4 @@ class DataLoaderPerformanceData {
156154 }
157155 }
158156 """
159-
160- static def expectedInitialDeferredData = [
161- shops : [
162- [id : " shop-1" , name : " Shop 1" , departments : null ],
163- [id : " shop-2" , name : " Shop 2" , departments : null ],
164- [id : " shop-3" , name : " Shop 3" , departments : null ],
165- ]
166- ]
167-
168- static def expectedInitialExpensiveDeferredData = [
169- shops : [
170- [id : " shop-1" , name : " Shop 1" , departments : null , expensiveDepartments : null ],
171- [id : " shop-2" , name : " Shop 2" , departments : null , expensiveDepartments : null ],
172- [id : " shop-3" , name : " Shop 3" , departments : null , expensiveDepartments : null ],
173- ],
174- expensiveShops : null
175- ]
176-
177- static def expectedListOfDeferredData = [
178- [[id : " department-1" , name : " Department 1" , products : [[id : " product-1" , name : " Product 1" ]]],
179- [id : " department-2" , name : " Department 2" , products : [[id : " product-2" , name : " Product 2" ]]],
180- [id : " department-3" , name : " Department 3" , products : [[id : " product-3" , name : " Product 3" ]]]]
181- ,
182-
183- [[id : " department-4" , name : " Department 4" , products : [[id : " product-4" , name : " Product 4" ]]],
184- [id : " department-5" , name : " Department 5" , products : [[id : " product-5" , name : " Product 5" ]]],
185- [id : " department-6" , name : " Department 6" , products : [[id : " product-6" , name : " Product 6" ]]]]
186- ,
187- [[id : " department-7" , name : " Department 7" , products : [[id : " product-7" , name : " Product 7" ]]],
188- [id : " department-8" , name : " Department 8" , products : [[id : " product-8" , name : " Product 8" ]]],
189- [id : " department-9" , name : " Department 9" , products : [[id : " product-9" , name : " Product 9" ]]]]
190- ,
191-
192- ]
193-
194-
195- static def deferredQuery = """
196- query {
197- shops {
198- id name
199- departments @defer {
200- id name
201- products {
202- id name
203- }
204- }
205- }
206- }
207- """
208-
209- static def expensiveDeferredQuery = """
210- query {
211- shops {
212- id name
213- departments @defer {
214- name
215- products @defer {
216- name
217- }
218- expensiveProducts @defer {
219- name
220- }
221- }
222- expensiveDepartments @defer {
223- name
224- products {
225- name
226- }
227- expensiveProducts {
228- name
229- }
230- }
231- }
232- expensiveShops @defer {
233- id name
234- }
235- }
236- """
237-
238- static def expectedExpensiveDeferredData = [
239- [[id : " exshop-1" , name : " ExShop 1" ], [id : " exshop-2" , name : " ExShop 2" ], [id : " exshop-3" , name : " ExShop 3" ]],
240- [[name : " Department 1" ,products :null , expensiveProducts :null ], [name : " Department 2" ,products :null , expensiveProducts :null ], [name : " Department 3" ,products :null , expensiveProducts :null ]],
241- [[name : " Department 1" , products : [[name : " Product 1" ]], expensiveProducts : [[name : " Product 1" ]]], [name : " Department 2" , products : [[name : " Product 2" ]], expensiveProducts : [[name : " Product 2" ]]], [name : " Department 3" , products : [[name : " Product 3" ]], expensiveProducts : [[name : " Product 3" ]]]],
242- [[name : " Department 4" ,products :null , expensiveProducts :null ], [name : " Department 5" ,products :null , expensiveProducts :null ], [name : " Department 6" ,products :null , expensiveProducts :null ]],
243- [[name : " Department 4" , products : [[name : " Product 4" ]], expensiveProducts : [[name : " Product 4" ]]], [name : " Department 5" , products : [[name : " Product 5" ]], expensiveProducts : [[name : " Product 5" ]]], [name : " Department 6" , products : [[name : " Product 6" ]], expensiveProducts : [[name : " Product 6" ]]]],
244- [[name : " Department 7" ,products :null , expensiveProducts :null ], [name : " Department 8" ,products :null , expensiveProducts :null ], [name : " Department 9" ,products :null , expensiveProducts :null ]],
245- [[name : " Department 7" , products : [[name : " Product 7" ]], expensiveProducts : [[name : " Product 7" ]]], [name : " Department 8" , products : [[name : " Product 8" ]], expensiveProducts : [[name : " Product 8" ]]], [name : " Department 9" , products : [[name : " Product 9" ]], expensiveProducts : [[name : " Product 9" ]]]],
246- [[name : " Product 1" ]],
247- [[name : " Product 1" ]],
248- [[name : " Product 2" ]],
249- [[name : " Product 2" ]],
250- [[name : " Product 3" ]],
251- [[name : " Product 3" ]],
252- [[name : " Product 4" ]],
253- [[name : " Product 4" ]],
254- [[name : " Product 5" ]],
255- [[name : " Product 5" ]],
256- [[name : " Product 6" ]],
257- [[name : " Product 6" ]],
258- [[name : " Product 7" ]],
259- [[name : " Product 7" ]],
260- [[name : " Product 8" ]],
261- [[name : " Product 8" ]],
262- [[name : " Product 9" ]],
263- [[name : " Product 9" ]],
264- ]
265157}
0 commit comments