Please give us (or document) the option to use Code First approach without saving the generated schema into a file.
See original GitHub issueI’m submitting a…
[ ] 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.
Current behavior
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
Expected behavior
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.
Minimal reproduction of the problem with instructions
Try using code first approach without specifying autoSchemaFile option.
What is the motivation / use case for changing the behavior?
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).
Environment
Nest version: 6.0.5
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
@venkatamandala I had this issue too. Solved it as follows:
.graphql
(so Schema First approach) once in order for theschema.gql
to be generated. So I made a very simpletemp.graphql
file and updated the module config like so:schema.gql
file. Then I changed it back to the config without thetypePaths
option, like so:schema.gql
get updated using the Code First approach. My guess is that theschema.gql
file simply needed to exist, but I’m unsure about that.Hope it helps!
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.<anonymous> (C:\work\UI\NEST\auth-app\node_modules\type-graphql\dist\schema\schema-generator.js:20:27)