Ninja Pokémon Master

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

    0.1.1 • 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

    Usage

    import fs from 'fs';
    import { getIntrospection, generateGraphQLSchema } from '@huiji/graphql-loader';
    
    (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 ${process.env.PERSONAL_ACCESS_TOKEN_TEST}`,
        },
      });
    
      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-loader

    DownloadsWeekly Downloads

    1

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    3.14 MB

    Total Files

    120

    Last publish

    Collaborators

    • duduluu
    • huijife-bot
    • reasno