@@ -4,31 +4,31 @@ import { ExecutionRequest, getOperationASTFromRequest, isAsyncIterable } from '@
44import { mapAsyncIterator , Plugin , TypedExecutionArgs } from '@envelop/core' ;
55import { GraphQLSchema , introspectionFromSchema } from 'graphql' ;
66
7- function getExecuteFnByArgs ( args : TypedExecutionArgs < any > , subschema : SubschemaConfig ) {
8- const transformationContext : Record < string , any > = { } ;
9- const originalRequest : ExecutionRequest = {
10- document : args . document ,
11- variables : args . variableValues as any ,
12- operationName : args . operationName ?? undefined ,
13- rootValue : args . rootValue ,
14- context : args . contextValue ,
15- } ;
16- const operationAST = getOperationASTFromRequest ( originalRequest ) ;
17- const delegationContext : DelegationContext = {
18- subschema ,
19- subschemaConfig : subschema ,
20- targetSchema : args . schema ,
21- operation : operationAST . operation ,
22- fieldName : '' , // Might not work
23- context : args . contextValue ,
24- rootValue : args . rootValue ,
25- transforms : subschema . transforms ,
26- transformedSchema : args . schema ,
27- skipTypeMerging : true ,
28- returnType : { } as any , // Might not work
29- } ;
30- const executor = subschema . executor ?? createDefaultExecutor ( subschema . schema ) ;
31- return async function subschemaExecute ( ) : Promise < any > {
7+ function getExecuteFn ( subschema : SubschemaConfig ) {
8+ return async function subschemaExecute ( args : TypedExecutionArgs < any > ) : Promise < any > {
9+ const transformationContext : Record < string , any > = { } ;
10+ const originalRequest : ExecutionRequest = {
11+ document : args . document ,
12+ variables : args . variableValues as any ,
13+ operationName : args . operationName ?? undefined ,
14+ rootValue : args . rootValue ,
15+ context : args . contextValue ,
16+ } ;
17+ const operationAST = getOperationASTFromRequest ( originalRequest ) ;
18+ const delegationContext : DelegationContext = {
19+ subschema,
20+ subschemaConfig : subschema ,
21+ targetSchema : args . schema ,
22+ operation : operationAST . operation ,
23+ fieldName : '' , // Might not work
24+ context : args . contextValue ,
25+ rootValue : args . rootValue ,
26+ transforms : subschema . transforms ,
27+ transformedSchema : args . schema ,
28+ skipTypeMerging : true ,
29+ returnType : { } as any , // Might not work
30+ } ;
31+ const executor = subschema . executor ?? createDefaultExecutor ( subschema . schema ) ;
3232 const transformedRequest = applyRequestTransforms (
3333 originalRequest ,
3434 delegationContext ,
@@ -69,10 +69,10 @@ export function useSubschema(subschema: SubschemaConfig): {
6969 data : introspectionFromSchema ( args . schema ) as any ,
7070 } ) ;
7171 }
72- setExecuteFn ( getExecuteFnByArgs ( args , subschema ) ) ;
72+ setExecuteFn ( getExecuteFn ( subschema ) ) ;
7373 } ,
74- onSubscribe ( { args , setSubscribeFn } ) {
75- setSubscribeFn ( getExecuteFnByArgs ( args , subschema ) ) ;
74+ onSubscribe ( { setSubscribeFn } ) {
75+ setSubscribeFn ( getExecuteFn ( subschema ) ) ;
7676 } ,
7777 } ;
7878
0 commit comments