{"id":16494885,"url":"https://github.com/stipsan/graphql-field-resolver-to-typescript","last_synced_at":"2026-05-13T03:39:14.787Z","repository":{"id":56057263,"uuid":"107420897","full_name":"stipsan/graphql-field-resolver-to-typescript","owner":"stipsan","description":"Export ts definitions from your server .graphql files to strictly type your field resolvers","archived":false,"fork":false,"pushed_at":"2023-12-15T08:17:38.000Z","size":164,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T06:14:35.469Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/stipsan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-18T14:38:28.000Z","updated_at":"2017-12-06T18:06:45.000Z","dependencies_parsed_at":"2024-10-11T14:16:08.750Z","dependency_job_id":"3af836d1-60f6-42e8-9dce-2d6a1f747bce","html_url":"https://github.com/stipsan/graphql-field-resolver-to-typescript","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":0.01666666666666672,"last_synced_commit":"61ac34cd2cf3b281057478b5dfa93b44cbc517e5"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stipsan%2Fgraphql-field-resolver-to-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stipsan%2Fgraphql-field-resolver-to-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stipsan%2Fgraphql-field-resolver-to-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stipsan%2Fgraphql-field-resolver-to-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stipsan","download_url":"https://codeload.github.com/stipsan/graphql-field-resolver-to-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241348206,"owners_count":19948157,"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":[],"created_at":"2024-10-11T14:16:06.531Z","updated_at":"2026-05-13T03:39:09.764Z","avatar_url":"https://github.com/stipsan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-field-resolver-to-typescript \u0026middot; [![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/graphql-field-resolver-to-typescript.svg?style=flat-square\u0026label=circleci)](https://circleci.com/gh/stipsan/graphql-field-resolver-to-typescript) [![npm version](https://img.shields.io/npm/v/graphql-field-resolver-to-typescript.svg?style=flat-square)](https://www.npmjs.com/package/graphql-field-resolver-to-typescript) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n\n\u003e This project started its life as a fork of [graphql-typewriter](https://www.npmjs.com/package/graphql-typewriter)\n\n# Usage\n\n## \u0026nbsp;\u0026nbsp;🚗 Local package.json\n```bash\n$ yarn add --dev graphql-field-resolver-to-typescript\n$ gqlfr2ts **/*.graphql -o schema.d.ts\n```\n\n## \u0026nbsp;🚙\u0026nbsp; Global dependency\n```bash\n$ npm install -g graphql-field-resolver-to-typescript\n$ gqlfr2ts **/*.graphql -o schema.d.ts\n```\n\n## 🏎💨\u0026nbsp; Using [npx](https://github.com/zkat/npx#npx1----execute-npm-package-binaries)\n```bash\n$ npx graphql-field-resolver-to-typescript **/*.graphql -o schema.d.ts\n```\n\n# API\n```bash\n$ gqlfr2ts \u003cinput\u003e\n```\n\n## `\u003cinput\u003e`\nYou can provide a list over files or use stdin to pipe from other cli programs.\n\n## `--output`, `-o` `path`\nOptionally specify where to write the output. If not specified it'll pipe to stdout so you can pipe it to any cli program you want.\n\n## Examples\n  ```bash\n$ gqlfr2ts schema.graphql\n```\nProcesses the file schema.graphql and prints to stdout\n\n```bash\n$ cat schema.graphql | gqlfr2ts --output schema.d.ts\n```\nProcesses the input from stdin and writes output to schema.d.ts\n```bash\n$ gqlfr2ts RootQuery.graphql User.graphql --output schema.d.ts\n```\nStitch a schema together and output a complete typescript definition for all the related resolvers\n```bash\n$ cat **/*.graphql | gqlfr2ts \u003e schema.d.ts\n```\nStitch a schema together from stdin and pipe it to stdout and use the shell to write output to file.\nThis is the most performant solution when you have a lot of files that combine to a big schema.\n\n## `.graphql` to `.ts` examples\n\n### input\n```graphql\ntype RootQuery {\n  # A field description\n  field1: TypeA\n  # Another field description\n  field2: TypeB\n}\n\n# A simple type\n# Multiline description\ntype TypeA {\n  name: String\n  size: Int\n}\n\n# Another more complex type\ntype TypeB {\n  nested: [TypeA]\n}\n\nschema {\n  query: RootQuery\n}\n```\n\n### output\n```typescript\n/* tslint:disable */\nimport { GraphQLResolveInfo } from 'graphql'\ntype ID = string\nexport type GraphqlField\u003cSource, Args, Result, Ctx\u003e =\n  | Result\n  | Promise\u003cResult\u003e\n  | ((\n      source: Source,\n      args: Args,\n      context: Ctx,\n      info: GraphQLResolveInfo\n    ) =\u003e Result | Promise\u003cResult\u003e)\n\nexport interface RootQuery\u003cCtx\u003e {\n  /**\n     * A field description\n     */\n  field1?: GraphqlField\u003cRootQuery\u003cCtx\u003e, {}, TypeA\u003cCtx\u003e | undefined, Ctx\u003e\n  /**\n     * Another field description\n     */\n  field2?: GraphqlField\u003cRootQuery\u003cCtx\u003e, {}, TypeB\u003cCtx\u003e | undefined, Ctx\u003e\n}\n\n/**\n * A simple type\n * Multiline description\n */\nexport interface TypeA\u003cCtx\u003e {\n  name?: GraphqlField\u003cTypeA\u003cCtx\u003e, {}, string | undefined, Ctx\u003e\n  size?: GraphqlField\u003cTypeA\u003cCtx\u003e, {}, number | undefined, Ctx\u003e\n}\n\n/**\n * Another more complex type\n */\nexport interface TypeB\u003cCtx\u003e {\n  nested?: GraphqlField\u003c\n    TypeB\u003cCtx\u003e,\n    {},\n    (TypeA\u003cCtx\u003e | undefined)[] | undefined,\n    Ctx\n  \u003e\n}\n\nexport interface field1Args {}\n\nexport interface field2Args {}\n\nexport const defaultResolvers = {}\n```\n\n### usage in resolvers\n\n```\n@TODO this will come soon, this is a very young project and there's a lot of edge cases to iron out\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstipsan%2Fgraphql-field-resolver-to-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstipsan%2Fgraphql-field-resolver-to-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstipsan%2Fgraphql-field-resolver-to-typescript/lists"}