@lite-v3/graphql-codegen
v0.7.1
Published
GraphQL Code Generator for automating type definitions generation
Downloads
28
Readme
@lite-v3/graphql-codegen
GraphQL Code Generator for automating type definitions generation
Installation
Install deps
# Use pnpm
pnpm add @lite-v3/graphql-codegen
# Use npm
npm i @lite-v3/graphql-codegen
# Use yarn
yarn add @lite-v3/graphql-codegen
Usage
This package only contains the necessary code (routines and supporting functions) to generate your own type definitions from your schema server to your target GraphQL file(s). You will still need to implement some sort of wrapper program to actually use it, for example creating a CLI to handle joining the logic provided in the routines folder.
Some of the highlight of the provided routines:
/routines/manage-schema ... manageSchema()
- Contains the step beginning with downloading the required schema, to partitioning it into a smaller chunks, to storing it in the memory (of our provided Introspection singleton). This function accepts a schema URL as its input./routines/find-files/gql ... findGqlFiles()
- Contains the step to find for any GraphQL file(s) in a given path. Accepts the target path to be scanned as its input./routines/gen-supporting-types/baseTypes ... generateBaseTypes()
- Contains the step to help generating the required base / scalar types from a given schema (which came from our Introspection singleton). This function does not need any input and will outputs a Typescript-compliant code as a raw string ready to be saved./routines/parse-gql-file ... parseOneGqlFile()
- Contains the step to generate the actual type definitions for a given GraphQL file. This function accepts the necessary information of the target GraphQL file and will save the generated code after it has ran successfully.
Code By WPE Team @Tokopedia