New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@stackup/codegen

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackup/codegen

Generate types for a GraphQL API

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
6
-92.77%
Maintainers
1
Weekly downloads
 
Created
Source

@stackup/codegen

Build Version License

A zero-config CLI tool to generate GraphQL type definitions and React Hooks. It's a thin wrapper around GraphQL code generator.

Install

$ yarn add @stackup/codegen --dev
$ yarn codegen --help
Usage: codegen [ROOT] [options]

Generate type definitions from GraphQL queries.

Options:
  -s, --schema <SCHEMA>  URL or file path to a GraphQL schema
  --suffix               append suffix (e.g. Mutation, Query)
  --immutable            generate readonly types
  -v, --version          output the version number
  -h, --help             display help for command

Usage

You have a directory of queries:

src/
  queries/
    posts.graphql
    users.graphql

Run the code generator:

$ yarn codegen src/queries --schema http://localhost:3000/graphql

Now, you have code!

src/
  queries/
    index.ts       <- This module exports a bunch of typed React Hooks
    schema.graphql <- This file contains your GraphQL schema
    posts.graphql
    users.graphql

FAQs

Package last updated on 11 May 2020

Related posts