{"id":16266150,"url":"https://github.com/victorgarciaesgi/simple-graphql-to-typescript","last_synced_at":"2025-03-16T13:31:01.435Z","repository":{"id":34883649,"uuid":"186852640","full_name":"victorgarciaesgi/simple-graphql-to-typescript","owner":"victorgarciaesgi","description":"🚀 🔄 Simple Typescript interface generator from a GraphQL api schemas or URL","archived":false,"fork":false,"pushed_at":"2022-12-11T23:17:04.000Z","size":3553,"stargazers_count":32,"open_issues_count":22,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T09:35:07.887Z","etag":null,"topics":["graphql","typescript","typescript-generator"],"latest_commit_sha":null,"homepage":"https://sgts.netlify.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/victorgarciaesgi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-15T15:17:22.000Z","updated_at":"2023-12-18T20:59:13.000Z","dependencies_parsed_at":"2023-01-15T10:00:24.235Z","dependency_job_id":null,"html_url":"https://github.com/victorgarciaesgi/simple-graphql-to-typescript","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorgarciaesgi%2Fsimple-graphql-to-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorgarciaesgi%2Fsimple-graphql-to-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorgarciaesgi%2Fsimple-graphql-to-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victorgarciaesgi%2Fsimple-graphql-to-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/victorgarciaesgi","download_url":"https://codeload.github.com/victorgarciaesgi/simple-graphql-to-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243815600,"owners_count":20352195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","typescript","typescript-generator"],"created_at":"2024-10-10T17:22:02.995Z","updated_at":"2025-03-16T13:31:00.731Z","avatar_url":"https://github.com/victorgarciaesgi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple-graphql-to-typescript generator\n\n🚀 🔄 Simple Typescript interface generator from a GraphQL api schemas or URL\n\n\u003cp align=\"center\"\u003e\n  \u003ca href='https://sgts.netlify.com/'\u003e\n    \u003cimg width='100' src=\"./media/logo.png\" alt=\"sgts logo\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![npm downloads][npm-total-downloads-src]][npm-downloads-href]\n\u003cimg src='https://img.shields.io/github/workflow/status/victorgarciaesgi/simple-graphql-to-typescript/Node.js%20CI'\u003e\n\u003cimg src='https://img.shields.io/npm/l/simple-graphql-to-typescript.svg'\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/simple-graphql-to-typescript.svg\n[npm-version-href]: https://www.npmjs.com/package/simple-graphql-to-typescript\n[npm-downloads-src]: https://img.shields.io/npm/dm/simple-graphql-to-typescript.svg\n[npm-total-downloads-src]: https://img.shields.io/npm/dt/simple-graphql-to-typescript.svg\n[npm-downloads-href]: https://www.npmjs.com/package/simple-graphql-to-typescript\n\n### Any help for writing test or adding options is greatly welcomed! 😁\n\n## Usage\n\nRefer to the full [documentation](https://sgts.netlify.com) !\n\n## New in 0.10.12\n\nAdded `apolloVersion` option.\n\n## **Installation**\n\nFor global use\n\n```bash\nnpm i -g simple-graphql-to-typescript\n#or\nyarn global add simple-graphql-to-typescript\n```\n\nFor local use\n\n```bash\nnpm i simple-graphql-to-typescript --save-dev\n#or\nyarn add -D simple-graphql-to-typescript\n```\n\n## Quick Exemples\n\n### With generated, fully-typed and abortable Apollo handlers, and generated fragments\n\n```bash\nsgts -e https://graphql.anilist.co/ -o ./generated.ts --codegen-functions --gen-fragments\n```\n\n```typescript\nimport { apiProvider } from './generated.ts';\nimport { ApolloClient } from '@apollo/client/core';\n\nconst sgts = apiProvider(\n  new ApolloClient({ uri: 'https://graphql.anilist.co/', cache: new InMemoryCache() })\n);\n// Declare the main api source with your ApolloClient constructor\n\nconst mediaListQuery = sgts.MediaList().$args({ sort: [MediaListSort.Added_time] });\n\n// You can still add fallback fragment by passing it to the first method\n// `sgts.MediaList(`id status`)...`\n// Or\n// `sgts.MediaList(gql`fragment MediaListFragment on MediaList { ... }`)...`\n\nconst mediaList = await mediaListQuery.$fetch();\nconsole.log(mediaList);\n\nmediaListQuery.$abort();\n// You can abort the query anytime\n```\n\n### With only GraphQL types transpiled to Typescript interfaces\n\n```bash\nsgts -e https://graphql.anilist.co/ -o ./generated.ts\n```\n\nPart of the generated output:\n\n```typescript\n...\n\n/** A user's general options */\nexport interface UserOptions {\n  /** The language the user wants to see media titles in*/\n  titleLanguage: Maybe\u003cUserTitleLanguage\u003e;\n  /** Whether the user has enabled viewing of 18+ content*/\n  displayAdultContent: Maybe\u003cboolean\u003e;\n  /** Whether the user receives notifications when a show they are watching aires*/\n  airingNotifications: Maybe\u003cboolean\u003e;\n  /** Profile highlight color (blue, purple, pink, orange, red, green, gray)*/\n  profileColor: Maybe\u003cstring\u003e;\n  /** Notification options*/\n  notificationOptions: Maybe\u003cNotificationOption[]\u003e;\n  /** The user's timezone offset (Auth user only)*/\n  timezone: Maybe\u003cstring\u003e;\n  /** Minutes between activity for them to be merged together. 0 is Never, Above 2 weeks (20160 mins) is Always.*/\n  activityMergeTime: Maybe\u003cnumber\u003e;\n}\n\n/** The language the user wants to see media titles in */\nexport enum UserTitleLanguage {\n  Romaji = 'ROMAJI',\n  English = 'ENGLISH',\n  Native = 'NATIVE',\n  Romaji_stylised = 'ROMAJI_STYLISED',\n  English_stylised = 'ENGLISH_STYLISED',\n  Native_stylised = 'NATIVE_STYLISED',\n}\n...\n```\n\n## Help\n\n```bash\nsgts -h\n```\n\n## **Options**\n\n| Option                      | Short syntax | Type                                         | Usage                                                                |\n| --------------------------- | ------------ | -------------------------------------------- | -------------------------------------------------------------------- |\n| --endpoint `\u003cendpoint\u003e`     | -e           | string(url)                                  | [See doc](https://sgts.netlify.com/options/endpoint.html)            |\n| --json `\u003cpath to json\u003e`     | -j           | string(path)                                 | [See doc](https://sgts.netlify.com/options/json.html)                |\n| --output `\u003cpath\u003e`           | -o           | string(path) \u003cbr\u003e _default_ `./generated.ts` | [See doc](https://sgts.netlify.com/options/output.html)              |\n| --codegen-functions         |              | boolean                                      | [See doc](https://sgts.netlify.com/options/codegen-functions.html)   |\n| --codegen-react-hooks       |              | boolean                                      | [See doc](https://sgts.netlify.com/options/codegen-react-hooks.html) |\n| --codegen-vue-hooks         |              | boolean                                      | [See doc](https://sgts.netlify.com/options/codegen-vue-hooks.html)   |\n| --gen-fragments             |              | boolean                                      | [See doc](https://sgts.netlify.com/options/gen-fragments.html)       |\n| --codegen-templates         |              | boolean                                      | [See doc](https://sgts.netlify.com/options/withGqlQueries.html)      |\n| --apolloVersion             |              | number \u003cbr\u003e _default_ `3`                    | [See doc](https://sgts.netlify.com/options/apolloVersion.html)       |\n| --customScalars `\u003cscalars\u003e` |              | {\"myScalar\": \"MyType\"}                       | [See doc](https://sgts.netlify.com/options/customScalars.html)       |\n| --prefix `\u003cprefix\u003e`         | -p           | string \u003cbr\u003e _default_ `null`                 | [See doc](https://sgts.netlify.com/options/prefix.html)              |\n| --suffix `\u003csuffix\u003e`         | -s           | string \u003cbr\u003e _default_ `null`                 | [See doc](https://sgts.netlify.com/options/suffix.html)              |\n| --header `\u003cheader\u003e`         |              | string \u003cbr\u003e _default_ `null`                 | [See doc](https://sgts.netlify.com/options/header.html)              |\n| --compileToJs               |              | boolean                                      | [See doc](https://sgts.netlify.com/options/jsMode.html)              |\n| --download                  | -D           | string \u003cbr\u003e _default_ `null`                 | [See doc](https://sgts.netlify.com/options/download.html)            |\n| generate                    |              | string \u003cbr\u003e _default_ `development`          | [See doc](https://sgts.netlify.com/options/config.html)              |\n| init                        |              |                                              | [See doc](https://sgts.netlify.com/options/init.html)                |\n\n## Roadmap\n\nI don't have much free time to develop feature I don't use, but feel free to send a PR!\n\n- [x] Export only Gql string\n- [x] Removed Query and mutation name in Apollo Hooks data\n- [x] Config file `.sgtsrc.js`\n- [x] Support Subscriptions for codegen-react-hooks\n- [x] Support Subscriptions for codegen-vue-hooks\n- [x] Support Subscriptions for codegen-template\n- [ ] Support Subscriptions for codegen-functions\n- [ ] Support UseLazyQuery Apollo Hook\n\n**In Progress**\n\n- [ ] Highlight new generated, modified or deleted types in terminal\n\n# License\n\nMIT\n\nVictor Garcia\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorgarciaesgi%2Fsimple-graphql-to-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictorgarciaesgi%2Fsimple-graphql-to-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictorgarciaesgi%2Fsimple-graphql-to-typescript/lists"}