{"id":14976012,"url":"https://github.com/ilijanl/graphql-hive-edge-client","last_synced_at":"2026-02-25T06:14:54.760Z","repository":{"id":176367500,"uuid":"657062051","full_name":"ilijaNL/graphql-hive-edge-client","owner":"ilijaNL","description":"Client for graphql-hive for the edge","archived":false,"fork":false,"pushed_at":"2023-06-27T05:58:08.000Z","size":212,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-20T00:29:57.282Z","etag":null,"topics":["analytics","cloudflare","edge","graphql","graphql-api","graphql-hive","workers"],"latest_commit_sha":null,"homepage":"https://github.com/ilijaNL/graphql-hive-edge-client","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/ilijaNL.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":"2023-06-22T08:29:15.000Z","updated_at":"2023-06-26T04:50:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8e0062e-a5c6-4852-a8af-c9263f8657aa","html_url":"https://github.com/ilijaNL/graphql-hive-edge-client","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.1428571428571429,"last_synced_commit":"ccd21b0f6bf201043a4ecc43de0c12665587bf52"},"previous_names":["ilijanl/graphql-hive-edge-client"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ilijaNL/graphql-hive-edge-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilijaNL%2Fgraphql-hive-edge-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilijaNL%2Fgraphql-hive-edge-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilijaNL%2Fgraphql-hive-edge-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilijaNL%2Fgraphql-hive-edge-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilijaNL","download_url":"https://codeload.github.com/ilijaNL/graphql-hive-edge-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilijaNL%2Fgraphql-hive-edge-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281361402,"owners_count":26487881,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["analytics","cloudflare","edge","graphql","graphql-api","graphql-hive","workers"],"created_at":"2024-09-24T13:53:08.158Z","updated_at":"2025-10-27T23:34:51.796Z","avatar_url":"https://github.com/ilijaNL.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Hive Edge Client\n\n**Note: Currently only supports usage reporting**\n\n[GraphQL Hive](https://graphql-hive.com) is a GraphQL schemas registry where you can host, manage\nand collaborate on all your GraphQL schemas and operations, compatible with all architecture: schema\nstitching, federation, or just a good old monolith.\n\nGraphQL Hive is currently available as a hosted service to be used by all. We take care of the heavy\nlifting behind the scenes be managing the registry, scaling it for your needs, to free your time to\nfocus on the most important things at hand.\n\n## Installation\n\n```\nnpm install graphql-hive-edge-client\n```\n\n## Usage Reporting configuration\n\n### Client Info\n\nThe schema usage operation information can be enriched with meta information that will be displayed\non the Hive dashboard in order to get a better understanding of the origin of an executed GraphQL\noperation.\n\n### Cloudflare Worker\n\n```ts\nimport { createUsageCollector, createHiveSendFn, UsageCollector } from 'graphql-hive-edge-client';\n\nexport interface Env {\n  HIVE_TOKEN: string;\n}\n\nlet collector: UsageCollector | null = null;\n\nexport default {\n  async fetch(_request: Request, env: Env, ctx: ExecutionContext): Promise\u003cResponse\u003e {\n    // singleton, we need the env.HIVE_TOKEN thus defining it inside fetch\n    if (!collector) {\n      const sendFn = createHiveSendFn(env.HIVE_TOKEN, {\n        clientName: 'cloudflare-worker-example',\n      });\n      collector = createUsageCollector({\n        send: (r) =\u003e {\n          console.info({ report: JSON.stringify(r, null, 2) });\n          return sendFn(r);\n        },\n        sampleRate: 1.0,\n        sendInterval: 2000,\n      });\n    }\n\n    // for test purposes use static definition, this definitions can be generated by codegen or be calculated runtime (worse performance)\n    const finish = collector.collect(\n      {\n        key: 'c844b925f03d2195287f817e0a67accb',\n        operationName: 'getProjects',\n        operation: 'query getProjects($limit:Int!){projects(filter:{pagination:{limit:$limit}type:FEDERATION}){id}}',\n        fields: [\n          'Query.projects',\n          'Query.projects.filter',\n          'Project.id',\n          'Int',\n          'FilterInput.pagination',\n          'FilterInput.type',\n          'PaginationInput.limit',\n          'ProjectType.FEDERATION',\n        ],\n      },\n      {\n        name: 'hive-example-worker',\n        version: '0.0.0',\n      }\n    );\n\n    // dummy fetch, this should be a fetch to some graphql server\n    await fetch('https://google.com');\n\n    ctx.waitUntil(finish({ ok: true }).catch((e) =\u003e console.error(e)));\n\n    return new Response('Collected!');\n  },\n};\n```\n\n### Usage with codegen\n\n`codegen.ts`:\n\n```ts\nimport type { CodegenConfig } from '@graphql-codegen/cli';\nimport { GenerateFn } from 'graphql-codegen-on-operations';\nimport { createCollector } from 'graphql-hive-edge-client';\n\nconst genFn: GenerateFn = (schema, { documents }) =\u003e {\n  const collect = createCollector(schema);\n  const result = documents.map((d) =\u003e collect(d.node, null));\n\n  return JSON.stringify(result, null, 2);\n};\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  documents: ['src/**/*.{ts,tsx,graphql}'],\n  ignoreNoDocuments: true,\n  generates: {\n    './src/__generated__/hive-ops.json': {\n      plugins: ['graphql-codegen-on-operations'],\n      config: {\n        gen: genFn,\n      },\n    },\n  },\n};\nexport default config;\n```\n\n`worker.ts`:\n\n```ts\nimport OperationHiveList from '@/__generated__/hive-ops.json';\nimport { createUsageCollector, createHiveSendFn, UsageCollector } from 'graphql-hive-edge-client';\n\nexport interface Env {\n  HIVE_TOKEN: string;\n}\n\nlet collector: UsageCollector | null = null;\n\nexport default {\n  async fetch(_request: Request, env: Env, ctx: ExecutionContext): Promise\u003cResponse\u003e {\n    // singleton, we need the env.HIVE_TOKEN thus defining it inside fetch\n    if (!collector) {\n      collector = createUsageCollector({\n        send: createHiveSendFn(env.HIVE_TOKEN, {\n          clientName: 'cloudflare-worker-example',\n        }),\n        sampleRate: 1.0,\n        sendInterval: 2000,\n      });\n    }\n\n    const hiveOp = OperationHiveList.find((i) =\u003e i.operationName === 'getProjects');\n\n    const finish = hiveOp\n      ? collector.collect(hiveOp, {\n          name: 'hive-example-worker',\n          version: '0.0.0',\n        })\n      : undefined;\n\n    // dummy fetch, this should be a fetch to some graphql server\n    await fetch('https://google.com');\n\n    finish \u0026\u0026 ctx.waitUntil(finish({ ok: true }).catch((e) =\u003e console.error(e)));\n\n    return new Response('Collected!');\n  },\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filijanl%2Fgraphql-hive-edge-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filijanl%2Fgraphql-hive-edge-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filijanl%2Fgraphql-hive-edge-client/lists"}