@lagunahealth/gql-generator

0.0.4 • Public • Published

gql-generator

CLI tool that generates graphql queries and mutations placeholders from graphql schema file.


how does it work

This CLI tool takes in a graphql schema as input and generates every query and mutation with input params with type placeholders and output types.

The queries and mutations are generated into two folders [query, mutation] and for each query/mutation a .gql file is created

gql-generator has three inputs:

  • input: path to graphql schema file
  • output: path to output folders to
  • depth: how deep to generate the type

example

we have the following schema file:

input CreateUserInput {
  firstName: String!
}

type Mutation {
  createUser(input: CreateUserInput!): User!
}

type Query {
  users: [User!]!
}

type User {
  id: String!
  username: String!
}

the output will be:

query/users.gql

query {
  users {
    id
    username
  }
}

mutation/createUser.gql

mutation {
  createUser (
    input: {
      firstName: String!
    }
  ) {
    id
    username
  }
}

How to Use

# install
npm install -g @lagunahealth/gql-generator

# see the usage
gql-generator --help

gql-generator --input ./schema.gql --output ./ --depth 6

Package Sidebar

Install

npm i @lagunahealth/gql-generator

Weekly Downloads

25

Version

0.0.4

License

MIT

Unpacked Size

9.3 kB

Total Files

7

Last publish

Collaborators

  • iddo-laguna
  • laguna-gabi