{"id":19855002,"url":"https://github.com/stepci/garph-gqty","last_synced_at":"2025-10-18T04:15:11.190Z","repository":{"id":101728020,"uuid":"609121369","full_name":"stepci/garph-gqty","owner":"stepci","description":"A tRPC-style client for Garph","archived":false,"fork":false,"pushed_at":"2023-06-17T17:03:46.000Z","size":310,"stargazers_count":79,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T20:46:22.461Z","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/stepci.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-03-03T12:23:16.000Z","updated_at":"2024-12-13T17:56:32.000Z","dependencies_parsed_at":"2024-11-12T14:11:33.171Z","dependency_job_id":"aa0211f5-79c0-49bc-b778-223c790147bf","html_url":"https://github.com/stepci/garph-gqty","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.06666666666666665,"last_synced_commit":"43ab0a33aaa047c7bbc78ebb65d09a610ed73216"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepci%2Fgarph-gqty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepci%2Fgarph-gqty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepci%2Fgarph-gqty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepci%2Fgarph-gqty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stepci","download_url":"https://codeload.github.com/stepci/garph-gqty/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969253,"owners_count":21673182,"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-11-12T14:11:22.483Z","updated_at":"2025-10-05T21:46:17.762Z","avatar_url":"https://github.com/stepci.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# @garph/gqty\n\n[tRPC](https://github.com/trpc/trpc)-style client for [Garph](https://github.com/stepci/garph), based on [GQty](https://github.com/gqty-dev/gqty)\n\n```\nnpm i @garph/gqty\n```\n\nExample:\n\n**schema.ts**\n\n```ts\nimport { g, buildSchema } from 'garph'\n\nexport const queryType = g.type('Query', {\n  greet: g.string()\n    .args({\n      name: g.string().optional().default('Max'),\n    })\n    .description('Greets a person')\n})\n\nconst schema = buildSchema({ g })\n```\n\n**client.ts**\n\n```ts\nimport { InferClient, createClient } from '@garph/gqty'\nimport { createScalarsEnumsHash, createGeneratedSchema } from '@garph/gqty/dist/utils'\nimport { schema, queryType } from './schema'\n\ntype ClientTypes = InferClient\u003c{ query: typeof queryType }\u003e\n\nexport const { useQuery, ... } = createClient\u003cClientTypes\u003e({\n  generatedSchema: createGeneratedSchema(schema),\n  scalarsEnumsHash: createScalarsEnumsHash(schema),\n  url: 'http://localhost:4000/graphql'\n})\n\n// Needed for the babel plugin\nexport { schema as compiledSchema }\n```\n\nUsing the client (React):\n\n**query.tsx**\n\n```tsx\nimport { useQuery } from './client'\n\nexport default function Example() {\n  const query = useQuery()\n  return \u003cp\u003e{ query.greet({ name: 'Mish' }) }\u003c/p\u003e\n}\n```\n\n## Subscriptions\n\n### With Server-Sent-Events\n\n```\nnpm i graphql-sse\n```\n\n```ts\nimport { createClient as createSubscriptionsClient } from 'graphql-sse'\n\nexport const { useSubscription, ... } = createClient\u003cClientTypes\u003e({\n  generatedSchema: createGeneratedSchema(schema),\n  scalarsEnumsHash: createScalarsEnumsHash(schema),\n  url: 'http://localhost:4000/graphql',\n  subscriptionClient: createSubscriptionsClient({\n    url: process.env.NODE_ENV === 'production' ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/graphql/stream` : 'http://localhost:3000/api/graphql/stream'\n  })\n})\n```\n\n## Using the Babel plugin (alpha)\n\nIn production, you might want to use the babel plugin in order to replace the runtime dependencies (such as `generatedSchema`, `scalarsEnumsHash`) in your client config with statically-generated artefacts.\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [[\"@garph/gqty/dist/plugin\", {\n    \"clientConfig\": \"./utils/client.ts\"\n  }]]\n}\n```\n\nWhere `clientConfig` is the path to the file where you call `createClient`\n\n*Special thanks to Vicary of GQty project for early feedback and helping to make `@garph/gqty` possible*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepci%2Fgarph-gqty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepci%2Fgarph-gqty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepci%2Fgarph-gqty/lists"}