Is there a way to get the GraphQL schema Object combined by NestJS v6?

Viewed 473

I'm looking for a way to get the combined GraphQL schema from NestJS v6, in order to mock the schema interface with addMockFunctionsToSchema from Apollo, for testing purposes.

i.e. https://www.apollographql.com/docs/graphql-tools/mocking/#addmockfunctionstoschema

In short, I need to get anyhow the schema object and call :

addMockFunctionsToSchema({ schema })

It looks like this was possible on the previous version of NestJS (v5):

e.g. https://github.com/alessandrodeste/graphql-nodejs-typescript/blob/master/src/app.module.ts#L24

Is it not possible anymore to achieve this? Thanks for your help!

1 Answers

Found a way to mock the schema. I didn't even know it was built-in Nest v6 :)

GraphQLModule.forRoot({
    ...
    mockEntireSchema: true,
    // it's even possible to pass your own mocks if needed
    // mocks: { ... }
    ...
});

Related