[ ] 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 we're using code first approach we need to autoSchemaFile option, otherwise we get an exception
UnhandledPromiseRejectionWarning: Error: Apollo Server requires either an existing schema, modules or typeDefs
When we use the code first approach we can simply use some flag to specify that's what we're doing now without saving the schema.gql file to the file system.
Try using code first approach without specifying autoSchemaFile option.
Sometimes deployment environments are immutable, and we don't have any need for the generated schema.gql file. The Apollo Server instance already knows everything and we can use the client for introspection without needing the file which only serves as documentation in this case and we might not need it in the code and/or we can't actually save it depending on the environment (would need to use tmp dir or something like that).
Nest version: 6.0.5
Thanks for reporting!
It should be available in the @next version ($ npm i @nestjs/graphql@next). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/[email protected]). Simply set autoSchemaFile: true instead of passing a filename.
Please, let me know if you face any issue.
Published as 6.2.0 ($ npm i @nestjs/graphql@latest). You will also have to update @nestjs/core to 6.2.0 ($ npm i @nestjs/core@latest)
Followed as you mentioend above, but still having issues
//Package json
"@nestjs/common": "^6.0.0",
"@nestjs/core": "^6.2.3",
"@nestjs/graphql": "^6.2.1",
//app.module.ts
GraphQLModule.forRoot({autoSchemaFile: true, debug: false, playground: false, context: ({ req }) => ({ req })}),
//Error
node:35352) UnhandledPromiseRejectionWarning: Error: Generating schema error
[0] at Function.
@venkatamandala I had this issue too. Solved it as follows:
.graphql (so Schema First approach) once in order for the schema.gql to be generated. So I made a very simple temp.graphql file and updated the module config like so:GraphQLModule.forRoot({
...
typePaths: ['./**/*.graphql'], // <-- add this
autoSchemaFile: 'schema.gql'
})
schema.gql file. Then I changed it back to the config without the typePaths option, like so:GraphQLModule.forRoot({
... // no more typePaths
autoSchemaFile: 'schema.gql'
})
schema.gql get updated using the Code First approach. My guess is that the schema.gql file simply needed to exist, but I'm unsure about that.Hope it helps!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.