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

0.0.7 • Public • Published

GraphQL Codegen

GraphQL Codegen is a powerful tool that helps you create GraphQL schemas using JSON. With an input schema based on the GraphQL type API, it should feel familiar to most users.

image

Installation

You can install graphql-codegen by running one of the commands below:

# npm
npm install @gwesseling/graphql-codegen

# yarn
yarn add @gwesseling/graphql-codegen

# pnpm
pnpm install @gwesseling/graphql-codegen

Usage

The usage of this package is straightforward.

import {codegen} from "@gwesseling/graphql-codegen";

// Using the default config
codegen()
    .then((result) => console.log(result))
    .catch((err) => console.log(err));

or

import {codegen} from "@gwesseling/graphql-codegen";

// Using a custom config
codegen({
    inputFile: "input.json",
    outputFile: "schema.ts",
})
    .then((result) => console.log(result))
    .catch((err) => console.log(err));

For a complete input examples, please refer to the examples folder. This folder contains a comprehensive JSON input, as well as the resulting output generated by the tool.

Options

GraphQL-Codegen accepts the following options:

Option Description Type Default
inputFile Path to a file containing a JSON schema string schema.json
outputFile Output file for the schema string schema.js

Package Sidebar

Install

npm i @gwesseling/graphql-codegen

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

14.3 kB

Total Files

8

Last publish

Collaborators

  • gwesseling