gatsby-plugin-generate-typings
Plugin that automatically generates TypeScript typings from the graphql schema
Last updated 4 months ago by stefan.baur .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gatsby-plugin-generate-typings 
SYNC missed versions from official npm registry.

Description

This plugin uses graphql-codegen to automatically generate typings for the gatsby graphql schema and your graphql queries.

How to install

using yarn: yarn add gatsby-plugin-generate-typings in your gatsby-config.js add

    {
      // automatically generate typings from graphql schema
      resolve: 'gatsby-plugin-generate-typings',
      options: {
        dest: './src/generated/graphql-types.d.ts',
      },
    },

to automatically generate ./src/generated/graphql-types.d.ts.

Available options

dest: the destination file name, where the typings will be written to.

When do I use this plugin?

When using gatsby-plugin-typescript it comes handy to have typings for your graphql schema and queries.

Examples of usage

When installed as above you can do

import { SiteTitleQueryQuery } from '../generated/graphql-types';

// ... somewhere in your render() function:

<StaticQuery
    query={graphql`
      query SiteTitleQuery {
        site {
          siteMetadata {
            title
          }
        }
      }
    `}
    render={(data: SiteTitleQueryQuery) => {

      // can use data.site.siteMetadata and have full Typescript Typings for it

    }}
  />

Current Tags

  • 0.9.9                                ...           latest (4 months ago)

6 Versions

  • 0.9.9                                ...           4 months ago
  • 0.9.8-r1                                ...           a year ago
  • 0.9.8                                ...           a year ago
  • 0.9.7                                ...           a year ago
  • 0.9.6                                ...           a year ago
  • 0.9.5                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |