5
5
GraphQLSchema ,
6
6
GraphQLString ,
7
7
parse ,
8
- execute as executeImplementation ,
8
+ execute as defaultExecuteImplementation ,
9
9
GraphQLList ,
10
+ ExecutionArgs ,
10
11
} from "graphql" ;
11
12
import { isAsyncIterable } from "@graphql-tools/utils" ;
12
13
import { InMemoryLiveQueryStore } from "./InMemoryLiveQueryStore" ;
@@ -28,6 +29,14 @@ function assertNoAsyncIterable(value: unknown) {
28
29
}
29
30
}
30
31
32
+ function execute (
33
+ store : InMemoryLiveQueryStore ,
34
+ params : ExecutionArgs ,
35
+ executeImplementation = defaultExecuteImplementation
36
+ ) {
37
+ return store . makeExecute ( executeImplementation ) ( params ) ;
38
+ }
39
+
31
40
const runAllPendingStuff = ( ) => new Promise ( ( res ) => setImmediate ( res ) ) ;
32
41
33
42
const getAllValues = async < T > ( values : AsyncIterable < T > ) => {
@@ -155,7 +164,7 @@ describe("conformance with default `graphql-js` exports", () => {
155
164
foo
156
165
}
157
166
` ) ;
158
- const result = store . execute ( {
167
+ const result = execute ( store , {
159
168
document,
160
169
schema,
161
170
} ) ;
@@ -176,7 +185,7 @@ describe("conformance with default `graphql-js` exports", () => {
176
185
}
177
186
` ) ;
178
187
179
- const result = store . execute ( {
188
+ const result = execute ( store , {
180
189
document,
181
190
schema,
182
191
} ) ;
@@ -197,7 +206,7 @@ describe("conformance with default `graphql-js` exports", () => {
197
206
}
198
207
` ) ;
199
208
200
- const result = store . execute ( {
209
+ const result = execute ( store , {
201
210
document,
202
211
schema,
203
212
} ) ;
@@ -224,7 +233,7 @@ describe("conformance with default `graphql-js` exports", () => {
224
233
}
225
234
` ) ;
226
235
227
- const result = store . execute ( {
236
+ const result = execute ( store , {
228
237
document,
229
238
schema,
230
239
} ) ;
@@ -249,7 +258,7 @@ it("returns a AsyncIterable that publishes a query result.", async () => {
249
258
}
250
259
` ) ;
251
260
252
- const executionResult = store . execute ( {
261
+ const executionResult = execute ( store , {
253
262
schema,
254
263
document,
255
264
} ) ;
@@ -278,7 +287,7 @@ it("returns a AsyncIterable that publishes a query result after the schema coord
278
287
}
279
288
` ) ;
280
289
281
- const executionResult = store . execute ( {
290
+ const executionResult = execute ( store , {
282
291
schema,
283
292
document,
284
293
} ) ;
@@ -325,7 +334,7 @@ it("returns a AsyncIterable that publishes a query result after the resource ide
325
334
}
326
335
` ) ;
327
336
328
- const executionResult = store . execute ( {
337
+ const executionResult = execute ( store , {
329
338
schema,
330
339
document,
331
340
} ) ;
@@ -383,7 +392,7 @@ it("does not publish when a old resource identifier is invalidated", async () =>
383
392
}
384
393
` ) ;
385
394
386
- const executionResult = store . execute ( {
395
+ const executionResult = execute ( store , {
387
396
schema,
388
397
document,
389
398
} ) ;
@@ -444,7 +453,7 @@ it("can be executed with polymorphic parameter type", () => {
444
453
}
445
454
` ) ;
446
455
447
- const executionResult = store . execute ( { schema, document } ) ;
456
+ const executionResult = execute ( store , { schema, document } ) ;
448
457
expect ( executionResult ) . toEqual ( {
449
458
data : {
450
459
foo : "queried" ,
@@ -463,7 +472,7 @@ it("can handle missing NoLiveMixedWithDeferStreamRule", async () => {
463
472
}
464
473
` ) ;
465
474
466
- const executionResult = await store . execute ( { schema, document } ) ;
475
+ const executionResult = await execute ( store , { schema, document } ) ;
467
476
if ( isAsyncIterable ( executionResult ) ) {
468
477
const asyncIterator = executionResult [ Symbol . asyncIterator ] ( ) ;
469
478
try {
@@ -508,7 +517,7 @@ it("can collect additional resource identifiers with 'extensions.liveQuery.colle
508
517
}
509
518
` ) ;
510
519
const store = new InMemoryLiveQueryStore ( ) ;
511
- const executionResult = await store . execute ( { schema, document } ) ;
520
+ const executionResult = await execute ( store , { schema, document } ) ;
512
521
513
522
assertAsyncIterable ( executionResult ) ;
514
523
@@ -539,7 +548,7 @@ it("adds the resource identifiers as a extension field.", async () => {
539
548
}
540
549
` ) ;
541
550
542
- const executionResult = store . execute ( {
551
+ const executionResult = execute ( store , {
543
552
schema,
544
553
document,
545
554
variableValues : {
@@ -624,7 +633,7 @@ it("can set the id field name arbitrarily", async () => {
624
633
}
625
634
` ) ;
626
635
627
- const executionResult = store . execute ( {
636
+ const executionResult = execute ( store , {
628
637
schema,
629
638
document,
630
639
variableValues : {
@@ -656,7 +665,7 @@ it("can throttle and prevent multiple publishes", async () => {
656
665
657
666
const store = new InMemoryLiveQueryStore ( ) ;
658
667
659
- const executionResult = store . execute ( {
668
+ const executionResult = execute ( store , {
660
669
schema,
661
670
document,
662
671
} ) ;
@@ -695,7 +704,7 @@ it("can throttle and publish new values after the throttle interval", async () =
695
704
696
705
const store = new InMemoryLiveQueryStore ( ) ;
697
706
698
- const executionResult = store . execute ( {
707
+ const executionResult = execute ( store , {
699
708
schema,
700
709
document,
701
710
} ) ;
@@ -733,7 +742,7 @@ it("can prevent execution by returning a string from validateThrottle", async ()
733
742
} ,
734
743
} ) ;
735
744
736
- let executionResult = store . execute ( {
745
+ let executionResult = execute ( store , {
737
746
schema,
738
747
document,
739
748
variableValues : {
@@ -742,7 +751,7 @@ it("can prevent execution by returning a string from validateThrottle", async ()
742
751
} ) ;
743
752
assertAsyncIterable ( executionResult ) ;
744
753
745
- executionResult = store . execute ( {
754
+ executionResult = execute ( store , {
746
755
schema,
747
756
document,
748
757
variableValues : {
@@ -777,7 +786,7 @@ it("can override the throttle interval by returning a number from validateThrott
777
786
} ,
778
787
} ) ;
779
788
780
- let executionResult = store . execute ( {
789
+ let executionResult = execute ( store , {
781
790
schema,
782
791
document,
783
792
variableValues : {
@@ -816,17 +825,15 @@ it("makeExecute calls the execute it is passed to resolve live queries", async (
816
825
817
826
const executePassedAtInitializationTime = jest . fn ( ) ;
818
827
executePassedAtInitializationTime . mockImplementation ( ( args ) =>
819
- executeImplementation ( args )
828
+ defaultExecuteImplementation ( args )
820
829
) ;
821
830
822
831
const executePassedToMakeExecute = jest . fn ( ) ;
823
832
executePassedToMakeExecute . mockImplementation ( ( args ) =>
824
- executeImplementation ( args )
833
+ defaultExecuteImplementation ( args )
825
834
) ;
826
835
827
- const store = new InMemoryLiveQueryStore ( {
828
- execute : executePassedAtInitializationTime ,
829
- } ) ;
836
+ const store = new InMemoryLiveQueryStore ( ) ;
830
837
831
838
const makeExecuteFn = store . makeExecute ( executePassedToMakeExecute ) ;
832
839
@@ -856,7 +863,7 @@ it("index via custom index field of type string", async () => {
856
863
] ,
857
864
} ) ;
858
865
859
- const execute = store . makeExecute ( executeImplementation ) ;
866
+ const execute = store . makeExecute ( defaultExecuteImplementation ) ;
860
867
861
868
const document = parse ( /* GraphQL */ `
862
869
query @live {
@@ -893,7 +900,7 @@ it("index via custom index field with string value", async () => {
893
900
} ,
894
901
] ,
895
902
} ) ;
896
- const execute = store . makeExecute ( executeImplementation ) ;
903
+ const execute = store . makeExecute ( defaultExecuteImplementation ) ;
897
904
898
905
const document = parse ( /* GraphQL */ `
899
906
query @live {
@@ -930,7 +937,7 @@ it("index via custom compound index", async () => {
930
937
} ,
931
938
] ,
932
939
} ) ;
933
- const execute = store . makeExecute ( executeImplementation ) ;
940
+ const execute = store . makeExecute ( defaultExecuteImplementation ) ;
934
941
935
942
const document = parse ( /* GraphQL */ `
936
943
query @live {
0 commit comments