https://github.com/gavinray97/graphql-operation-generator
Automatically generate GraphQL operations from a schema
https://github.com/gavinray97/graphql-operation-generator
Last synced: 28 days ago
JSON representation
Automatically generate GraphQL operations from a schema
- Host: GitHub
- URL: https://github.com/gavinray97/graphql-operation-generator
- Owner: GavinRay97
- Created: 2020-08-17T03:29:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-16T05:17:32.000Z (over 3 years ago)
- Last Synced: 2025-04-20T11:08:52.942Z (about 1 month ago)
- Language: TypeScript
- Size: 89.8 KB
- Stars: 6
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
graphql-operation-generator
=======================Automatically generate GraphQL operations from a schema
[](https://oclif.io)
[](https://npmjs.org/package/graphql-operation-generator)
[](https://npmjs.org/package/graphql-operation-generator)
[](https://github.com/GavinRay97/graphql-operation-generator/blob/master/package.json)- [graphql-operation-generator](#graphql-operation-generator)
- [Usage](#usage)# Usage
```sh-session
$ npm install -g graphql-operation-generator
$ graphql-operation-generator --help
Automatically generate GraphQL operations from a schemaUSAGE
$ graphql-operation-generatorOPTIONS
-d, --depth=depth [default: 1] Maximum depth for nested operation selection sets to generate.
-h, --help show CLI help
-o, --operations=query|mutation|subscription
-s, --schema=schema Optional file path to a GraphQL schema from the current directory, if not piping through stdin
-v, --version show CLI version
--all Generates all operations, equivalent to setting "--operations query mutation subscription"
--mutation-prefix=mutation-prefix
--query-prefix=query-prefix
--subscription-prefix=subscription-prefixEXAMPLES
# Pipe from stdin:
$ cat my-schema.graphql | graphql-operation-generator --all
$ cat my-schema.graphql | graphql-operation-generator --operations queries mutations --depth 2
# Or use a filepath to a schema:
$ graphql-query-generator --all --schema=./my-schema.graphql
---------------------------------------------------------------------------
# 1. Use "graphqurl" to save introspection schema to file:
$ npx gq http://localhost:8080/v1/graphql --introspect > schema.graphql# 2. Use "graphql-operation-generator" to create queries, mutations, and subscriptions for every type in the schema:
$ cat schema.graphql | graphql-operation-generator --all > queries.graphql# 3. Use "graphql-code-generator" to generate Typescript types and a query client for every operation:
$ npx graphql-code-generator
```