Skip to content

A Gatsby plugin that automatically emits GraphQL TypeScript types

License

Notifications You must be signed in to change notification settings

damassi/gatsby-plugin-emit-graphql-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gatsby-plugin-emit-graphql-types

A Gatsby plugin that automatically emits GraphQL TypeScript types via relay-language-compiler-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.

This is a limitation in Gatsby's current architecture. See this issue 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 section of the gatsby docs and then in gatsby-config.js, add the plugin:

plugins: [
  "gatsby-plugin-emit-graphql-types"
]

If also accepts these configuration options:

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
    }
  }
]

About

A Gatsby plugin that automatically emits GraphQL TypeScript types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published