Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content model changes are not picked up for type generation #82

Closed
nibtime opened this issue May 23, 2020 · 3 comments · Fixed by #79
Closed

content model changes are not picked up for type generation #82

nibtime opened this issue May 23, 2020 · 3 comments · Fixed by #79
Labels
enhancement New feature or request

Comments

@nibtime
Copy link

nibtime commented May 23, 2020

First of all, thanks for providing this awesome plugin!

Schema and type generation works perfectly and is very fast. The only thing that doesn't seem to work is picking up content model changes (i.e. Markdown). If I add, alter or remove a Markdown frontmatter field while running gatsby develop, the change is reflected in the remote schema at localhost:8000/___graphql, but generated schemas by gatsby-plugin-typegen are not updated, that only happens once when executing gatsby develop. If I just remove and add known properties from queries or fragments, type generation works instantly as expected.

I use the plugin together with the Apollo VS Code extension and consume the remote schema at localhost:8000/___graphql instead of the generated schema file in apollo.config.js to get IntelliSense for content model updates. However, type generation of the plugin fails, because it seems to not know about the schema update:

[typegen] An error on codegen
    GraphQLDocumentError: Cannot query field "testValue" on type "MarkdownRemarkFrontmatterForm".



  AggregateError: GraphQLDocumentError: Cannot query field "testValue" on type "MarkdownRemarkFrontmatterForm".
  
  - validate-documents.js:53 Object.checkValidationErrors
    [iacm-site]/[gatsby-plugin-typegen]/[@graphql-codegen]/core/dist/common/src/validate-documents.js:53:15
  
  - codegen.js:63 codegen
    [iacm-site]/[gatsby-plugin-typegen]/dist/graphql-codegen-core/src/codegen.js:63:9

Is it intentional that schema updates only happen at startup (e.g. performance reasons) or is this due to some misconfiguration by me or a bug?

@cometkim
Copy link
Owner

cometkim commented May 23, 2020

Hello @nibtime, thank you for reporting this!

Schema registration is currently happening only once the startup. I just couldn't consider the schema change scenario (forgot that the remark source changes it dynamically in runtime 😅)

I'll fix it in the right next version! #79

@cometkim cometkim added the enhancement New feature or request label May 23, 2020
This was referenced May 23, 2020
cometkim added a commit that referenced this issue May 23, 2020
* release: prepare patch

* change stratege patch to minor

* doc: add changelog

* chore(config): Change ESLint config to extend cometjs preset

* chore: import type separately

* feat: emit schema when it changed in dev (#83)

* feat: emit schema when it changed in dev

* doc: update README

* chore: fix lint

* chore: bump-up yarn binary

* chore: bump-up yarn version plugin

* chore: bump-up dependencies

* Hey berry, why I need to install the babel-plugin-typescript which is already in the dependency tree?

* chore: fix for new lint rules

* chore: remove unused

Fixes #80 
Fixes #81 
Fixes #82
@cometkim
Copy link
Owner

Hey @nibtime, I just fixed this and published v2.2.0

Hope you enjoy :)

@nibtime
Copy link
Author

nibtime commented May 23, 2020

@cometkim

wow, that was fast! 😄. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants