From e51dbeada72a432290546384d011cf096846a9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Belli?= Date: Tue, 21 Mar 2023 19:13:16 +0100 Subject: [PATCH] feat: support custom fieldResolver in createSchemaForApollo --- packages/graphql-modules/src/application/apollo.ts | 7 +++++-- packages/graphql-modules/src/application/types.ts | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/graphql-modules/src/application/apollo.ts b/packages/graphql-modules/src/application/apollo.ts index 6f51654dfa..7e1b0a21da 100644 --- a/packages/graphql-modules/src/application/apollo.ts +++ b/packages/graphql-modules/src/application/apollo.ts @@ -1,5 +1,5 @@ import { wrapSchema } from '@graphql-tools/wrap'; -import { DocumentNode, execute, GraphQLSchema } from 'graphql'; +import { DocumentNode, execute, ExecutionArgs, GraphQLSchema } from 'graphql'; import { uniqueId } from '../shared/utils'; import { InternalAppContext } from './application'; import { ExecutionContextBuilder } from './context'; @@ -47,7 +47,9 @@ export function apolloSchemaCreator({ contextBuilder: ExecutionContextBuilder; schema: GraphQLSchema; }) { - const createApolloSchema = () => { + const createApolloSchema = ({ + fieldResolver, + }: Pick = {}) => { const sessions: Record< string, { @@ -114,6 +116,7 @@ export function apolloSchemaCreator({ variableValues: input.variables as any, rootValue: input.rootValue, operationName: input.operationName, + fieldResolver, }) as any ) .finally(destroy); diff --git a/packages/graphql-modules/src/application/types.ts b/packages/graphql-modules/src/application/types.ts index 18191b42d5..1e51438917 100644 --- a/packages/graphql-modules/src/application/types.ts +++ b/packages/graphql-modules/src/application/types.ts @@ -4,6 +4,7 @@ import { DocumentNode, GraphQLSchema, ExecutionResult, + ExecutionArgs, } from 'graphql'; import type { Provider, Injector } from '../di'; import type { Resolvers, Module, MockedModule } from '../module/types'; @@ -70,7 +71,9 @@ export interface Application { /** * @deprecated Use `createApolloExecutor`, `createExecution` and `createSubscription` methods instead. */ - createSchemaForApollo(): GraphQLSchema; + createSchemaForApollo( + options?: Pick + ): GraphQLSchema; /** * Experimental */