fix(gatsby-plugin-graphql): Export schema types #916
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
Gatsby plugin graphql currently exports types for each query you do. If you, for inistance, add a query like:
This would generate a typings file like
As you can see, the type
SelectedFacets
was not defined on the typings. This is because the library I'm using expect that we generate these typings alongside another file of the graphql's schema, where thisSelectedFacets
input type would be defined.This PR adds just that. It outputs a new file on the path
src/typings/schema.graphql.d.ts
. This is a global definition file that typescript can read and reason about.If you don't want it to output the file over this path, you can use the new param of this plugin called schemaPath like:
How to test it?
vtex-sites/base.store#12
https://github.com/vtex-sites/btglobal.store/pull/807
https://github.com/vtex-sites/marinbrasil.store/pull/619