Nouveau Papier Mâché

    This package has been deprecated

    Author message:

    use @graphql-codegen/typescript-document-nodes package

    graphql-codegen-typescript-document-nodes
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.1 • Public • Published

    graphql-codegen-typescript-document-nodes

    Build Status npm

    This is a plugin for GraphQL Code Generator that generates Typescript source file from GraphQL files.

    Generated modules export GraphQL as an AST document nodes. Modules use graphql-tag module.

    Requirements

    This package requires ES6 with Node >= 8.

    Usage

    Configuration in codegen.yml file:

    overwrite: true
    schema: 'schema/index.json'
    documents: 'operations/*.graphql'
    generates:
      operations/index.ts:
        plugins:
          - graphql-codegen-typescript-document-nodes
        config:
          namingConvention: lowerCamelCase
          nameSuffix: Query

    With GitHub GraphQL API v4 schema and following GraphQL operation:

    query Viewer {
      viewer {
        login
        name
      }
    }

    It will generate following Typescript code:

    import { DocumentNode } from 'graphql';
    import gql from 'graphql-tag';
     
    export const viewerQuery: DocumentNode = gql`
      query Viewer {
        viewer {
          login
          name
        }
      }
    `;

    Configuration

    namingConvention

    Allow you to override the naming convention of the output. You can either override all namings, or specify an object with specific custom naming convention per output. The format of the converter must be a valid module#method. You can also use "keep" to keep all GraphQL names as-is. Additionally you can set transformUnderscore to true if you want to override the default behaviour, which is to preserve underscores.

    Override All Names:

    config:
      namingConvention: change-case#lowerCase

    Upper-case enum values:

    config:
      namingConvention: change-case#pascalCase

    Keep:

    config:
      namingConvention: keep

    Transform Underscores:

    config:
      namingConvention: change-case#pascalCase
      transformUnderscore: true

    namePrefix

    Adds a prefix to GraphQL operation name

    nameSuffix

    Adds a suffix to GraphQL operation name

    License

    Copyright (c) 2019 Piotr Roszatycki piotr.roszatycki@gmail.com

    MIT

    Keywords

    none

    Install

    npm i graphql-codegen-typescript-document-nodes

    DownloadsWeekly Downloads

    0

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    26.1 kB

    Total Files

    14

    Last publish

    Collaborators

    • dex4er