'How to transform GQL schema on its generating? [NestJS]
I want to apply prefixes to all types, mutations, etc. in GQL schema generated. Here is my config factory:
useFactory: (configService: ConfigService) => ({
    autoSchemaFile: 'schema.graphql',
    sortSchema: true,
    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
    transformSchema: schema => wrapSchema({
        schema,
        transforms: [
            new RenameTypes(name => `New${name}`),
            new RenameObjectFields((_, fieldName) => `new_${fieldName}`),
            new RenameInterfaceFields((_, fieldName) => `new_${fieldName}`),
            new RenameInputObjectFields((_, fieldName) => `new_${fieldName}`),
        ],
    }),
    playground: configService.get<string>('NODE_ENV') === 'development',
    context: ({ req, res }): { req: Request; res: Response } => ({
        req,
        res,
    }),
    tracing: configService.get<string>('NODE_ENV') === 'development',
}),
wrapSchema works fine but as a result I'm still getting old schema... It seems like transformSchema is not working at all. How to fix it?
Solution 1:[1]
So, after exploring the source code of @nestjs/graphql I found out that in order to make transformSchema option work I have to set transformAutoSchemaFile: true because I use autoSchemaFile.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Denis Rybkin | 
