Skip to content

victorgarciaesgi/simple-graphql-to-typescript

Repository files navigation

Simple-graphql-to-typescript generator

πŸš€ πŸ”„ Simple Typescript interface generator from a GraphQL api schemas or URL

sgts logo

npm version npm downloads npm downloads

Any help for writing test or adding options is greatly welcomed! 😁

Usage

Refer to the full documentation !

New in 0.10.12

Added apolloVersion option.

Installation

For global use

npm i -g simple-graphql-to-typescript #or yarn global add simple-graphql-to-typescript

For local use

npm i simple-graphql-to-typescript --save-dev #or yarn add -D simple-graphql-to-typescript

Help

sgts -h

Documentation

Option Short syntax Type Usage
--endpoint <endpoint> -e string(url) See doc
--json <path to json> -j string(path) See doc
--output <path> -o string(path)
default ./generated.ts
See doc
--codegen-functions boolean See doc
--codegen-react-hooks boolean See doc
--codegen-vue-hooks boolean See doc
--gen-fragments boolean See doc
--codegen-templates boolean See doc
--apolloVersion number
default 3
See doc
--customScalars <scalars> {"myScalar": "MyType"} See doc
--prefix <prefix> -p string
default null
See doc
--suffix <suffix> -s string
default null
See doc
--header <header> string
default null
See doc
--compileToJs boolean See doc
--download -D string
default null
See doc
generate string
default development
See doc
init See doc

Roadmap

I don't have much free time to develop feature I don't use, but feel free to send a PR!

  • Export only Gql string
  • Removed Query and mutation name in Apollo Hooks data
  • Config file .sgtsrc.js
  • Support Subscriptions for codegen-react-hooks
  • Support Subscriptions for codegen-vue-hooks
  • Support Subscriptions for codegen-template
  • Support Subscriptions for codegen-functions
  • Support UseLazyQuery Apollo Hook

In Progress

  • Highlight new generated, modified or deleted types in terminal

License

MIT

Victor Garcia

About

πŸš€ πŸ”„ Simple Typescript interface generator from a GraphQL api schemas or URL

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5