If you are building apps using GatsbyJS, you can use GraphQL Code Generator to generate TypeScript types.
The codegen knows automatically to look for the import of the
graphql tag for
Using the following config file, it should cover everything specific to Gastby:
Now, the codegen should be able to load your GraphQL operations from your source code, and also load all the internal fragments from
The glob expression above should get you started quickly, but note that it's very broad and might load many files that matches the
If you are having issues with this glob expression, or if you are seeing performance issues, please note that you need to narrow this expression to the bare minimum that is being loaded by your Gatsby instance.
There are also community Gatsby plugins that integrate with @graphl-codegen: