Skip to content

GraphQL Code Generator plugin for generating a .ts or .js file exposing the schema in a graphql-tag from a given schema

Notifications You must be signed in to change notification settings

emolr/graphql-tag-schema

Repository files navigation

Graphql-tag Schema

graphql-tag-schema plugin prints the merged schema as graphql-tag in a .ts or .js to be used with eg. Apollo Client. If multiple schemas are provided, they will be merged and printed as one schema.

The .ts or .js file exposes a JavaScript template literal tag that parses GraphQL query strings into the standard GraphQL AST. Make sure to have graphql-tag installed in the application you are using the output.

Installation

$ yarn add -D graphql-tag-schema

Examples

# ...
schema:
  - 'http://localhost:3000/graphql'
  - './src/**/*.graphql'
generates:
  path/to/file.ts:
    plugins:
      - graphql-tag-schema
  path/to/file.js:
    plugins:
      - graphql-tag-schema

Result

import gql from 'graphql-tag'

export const schema = gql`
    type ExampleType {
        example: Boolean!
    }
`

export default schema

About

GraphQL Code Generator plugin for generating a .ts or .js file exposing the schema in a graphql-tag from a given schema

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published