https://github.com/damassi/gatsby-plugin-emit-graphql-types
A Gatsby plugin that automatically emits GraphQL TypeScript types
https://github.com/damassi/gatsby-plugin-emit-graphql-types
Last synced: 12 months ago
JSON representation
A Gatsby plugin that automatically emits GraphQL TypeScript types
- Host: GitHub
- URL: https://github.com/damassi/gatsby-plugin-emit-graphql-types
- Owner: damassi
- License: mit
- Created: 2019-02-02T23:21:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-21T18:23:41.000Z (about 7 years ago)
- Last Synced: 2025-07-04T09:06:50.577Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.68 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gatsby-plugin-emit-graphql-types
A Gatsby plugin that automatically emits GraphQL TypeScript types via [relay-language-compiler-typescript](https://github.com/relay-tools/relay-compiler-language-typescript).
## Wait! Large bold caveat!
As it currently stands, this plugin *will not work* in projects that use plugins that export fragments, and will fail to emit types. This includes
- `gatsby-transformer-sharp`
- `gatsby-source-contentful`
- `gatsby-source-datocms`
- `gatsby-source-sanity`
and other plugins that take advantage of [`gatsby-image`](https://www.gatsbyjs.org/packages/gatsby-image/#fragments).
This is a limitation in Gatsby's current architecture. See [this issue](https://github.com/graphql/graphiql/issues/612) or more information. Please use at your own risk.
## Setup
This plugin is intentionally unpublished due to the issue above. If you would like to give this a spin see the [local plugins](https://www.gatsbyjs.org/docs/loading-plugins-from-your-local-plugins-folder/) section of the gatsby docs and then in `gatsby-config.js`, add the plugin:
```js
plugins: [
"gatsby-plugin-emit-graphql-types"
]
```
If also accepts these configuration options:
```js
plugins: [
{
resolve: "gatsby-plugin-emit-graphql-types",
options: {
/**
* The root location of source files
*/
src: './src',
/**
* The location to save the schema to. This is used by the compiler to emit types
*/
schema: './schema.graphql',
/**
* The relay compiler supports different languages, such as flow. Right now
* this plugin only supports TypeScript, but willing to accept PRs.
*/
language: 'typescript',
/**
* Location where generated types are saved to
*/
artifactDirectory: './src/__generated__',
/**
* If true, the compiler will watch `src` for changes and recompile
*/
watch: false
}
}
]