[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
When using the autoSchemaFile option the printed schema is not sorted. Additionally, when using forward references between modules the order of the generated schema is indeterminate since the order of instantiation is indeterminate. This causes the schema to possibly change every time the server (re)loads.
I should be able to provide an option to the GraphQLModule to ensure that the printed schema is sorted.
I have attempted to solve this issue with transformSchema:
import { GraphQLSchema, lexicographicSortSchema } from 'graphql';
...
GraphQLModule.forRoot({
...
transformSchema: (schema: GraphQLSchema) => lexicographicSortSchema(schema),
});
This correctly and consistently orders the schema for introspection, etc. However transformSchema is not applied to the autoSchemaFile generation:
I am willing to submit a PR to resolve this issue, either by:
transformSchema to the autoSchemaFile generationGraphQLModule to sort the schema (both for introspection, etc. and for autoSchemaFile)Thanks for Nest and for your guidance here! 馃憤
Nest version: 7.0.13
For Tooling issues:
- Node version: v14.3.0
- Platform: Mac
Applying transformSchema to the autoSchemaFile generation
Adding a boolean option to GraphQLModule to sort the schema (both for introspection, etc. and for autoSchemaFile)
I think both would be very useful! PRs are more than welcome :)
@kamilmysliwiec I've pushed #996 to apply transformSchema when writing an autoSchemaFile. I can send a PR for a sort option later.
Most helpful comment
I think both would be very useful! PRs are more than welcome :)