Question: Updating the schema
We've just started a new project where the schema changes a lot during development.
The schema is downloaded, but when the schema changes it doesn't get updated. Is the downloadSchema only meant to be used for the first time to get the schema?
Is it also possible to manually trigger the download of the schema and the generation of types with new package used, or should i just delete the schema file and the .nuxt files and let it regenerate.
When downloadSchema is enabled, the module will download it initially on module init. During dev mode however, the schema doesn't get automatically updated. Only if any of your GraphQL documents changes and it fails validation, the module will prompt you in the console if you want to re-download the schema.
So I guess currently the only way for you to trigger an update of the schema would be to forcefully save an invalid GraphQL file and then accept the prompt. But this is far away from a satisfying solution.
I could add a button in the module's tab in Nuxt Dev Tools to trigger a schema update. WDYT?
Ah, didn't see the prompt to re-download the schema but now i do. Adding it to Nuxt Dev Tools could be a solution, however i am not a big user of the nuxt dev tools, but use the vue devtools more.
For me the best solution would be through command line, by adding a script in package json. Don't know if anything is possible through nuxi, or maybe by referencing a part of the code from the module to trigger the download schema. This would give more flexibility.
As a quickfix i can use the invalid schema and the command prompt, which seems to work fine.
I can definitely provide a new method on the object returned by useGraphqlModuleContext() to force download the schema and rebuild the state. This would give full flexibility to handle this.
In addition, I can implement a server handler in dev mode (e.g. /__nuxt_graphql_middleware/download-schema) that, when called, will call the "updateSchema" method. Then it would be possible to add a npm script with curl to this endpoint.
That would be a great feature for the update schema.