Ninja Pirate Mutants

    @huiji/graphql-tools
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.4 • Public • Published

    graphql-tools

    A tool kit to generate schema for GraphQL and type declaration for other languages.

    Present Supports

    • GraphQL Schema (IDL format)
    • TypeScript Declaration

    Install

    npm install -D @huiji/graphql-tools
    # or
    yarn add -D @huiji/graphql-tools

    Usage

    import fs from 'fs';
    import { getIntrospection, generateGraphQLSchema } from '@huiji/graphql-tools';
    
    (async () => {
      const intro = await getIntrospection('https://graphql.xy.huijitrans.com/graphql');
    
      const schema = generateGraphQLSchema(intro);
      fs.writeFileSync('.tmp/gamelib.gql', schema);
    
      const declaration = generateTypeScriptDeclaration(intro);
      fs.writeFileSync('.tmp/gamelib.d.ts', schema);
    })();
    
    (async () => {
      const intro = await getIntrospection('https://api.github.com/graphql', {
        headers: {
          Authorization: `bearer <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>`,
        },
      });
    
      const schema = generateGraphQLSchema(intro);
      fs.writeFileSync('.tmp/github.gql', schema);
    
      const declaration = generateTypeScriptDeclaration(intro, {
        customScalars: {
          Date: 'string',
          DateTime: 'string',
          HTML: 'string',
          URI: 'string',
        },
      });
      fs.writeFileSync('.tmp/github.d.ts', schema);
    })();

    Install

    npm i @huiji/graphql-tools

    DownloadsWeekly Downloads

    0

    Version

    0.3.4

    License

    MIT

    Unpacked Size

    132 kB

    Total Files

    66

    Last publish

    Collaborators

    • duduluu
    • huijife-bot
    • reasno