{"id":20844328,"url":"https://github.com/bootnodedev/db-subgraph","last_synced_at":"2025-12-11T22:43:16.535Z","repository":{"id":255508127,"uuid":"852303288","full_name":"BootNodeDev/db-subgraph","owner":"BootNodeDev","description":"Opinionated Subgraph setup for dAppBooster","archived":false,"fork":false,"pushed_at":"2024-09-11T11:14:43.000Z","size":155,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-19T03:48:03.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BootNodeDev.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":"2024-09-04T15:21:29.000Z","updated_at":"2024-09-11T11:14:46.000Z","dependencies_parsed_at":"2024-09-05T21:36:38.965Z","dependency_job_id":"799a1016-fb62-4967-a16d-0f55c3218755","html_url":"https://github.com/BootNodeDev/db-subgraph","commit_stats":null,"previous_names":["bootnodedev/db-subgraph"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BootNodeDev%2Fdb-subgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BootNodeDev%2Fdb-subgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BootNodeDev%2Fdb-subgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BootNodeDev%2Fdb-subgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BootNodeDev","download_url":"https://codeload.github.com/BootNodeDev/db-subgraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243205246,"owners_count":20253426,"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-18T02:09:21.755Z","updated_at":"2025-12-11T22:43:11.485Z","avatar_url":"https://github.com/BootNodeDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dAppBooster Subgraph Plugin\n\nThis package provides a flexible and reusable solution for generating GraphQL clients using @graphql-codegen/cli, integrated with @tanstack/react-query. It simplifies the process of setting up and managing GraphQL code generation for multiple subgraphs.\n\n## Installation\n\nThis package uses pnpm as the preferred package manager. First, install the package along with other required dependencies:\n\n```bash\npnpm add @bootnodedev/db-subgraph graphql graphql-request\n```\n\nThen, add the development dependencies:\n\n```bash\npnpm add -D @graphql-codegen/cli @graphql-typed-document-node/core\n```\n\nThis separation ensures that the runtime dependencies are installed in your main dependencies, while the code generation tools are kept in your development dependencies.\n\n## Usage\n\n### 1. Set Up CodeGen Configuration\n\nCreate a codegen file (e.g., `src/subgraphs/codegen.ts`) in your project:\n\n```typescript\nimport { generateCodegenConfig } from \"@bootnodedev/db-subgraph\";\nimport { loadEnv } from \"vite\";\n\nconst env = loadEnv(\"subgraphs\", process.cwd(), \"\");\n\nexport default generateCodegenConfig({\n  subgraphs: [\n    {\n      apiKey: env.PUBLIC_SUBGRAPHS_API_KEY,\n      chainsResourceIds: env.PUBLIC_SUBGRAPHS_CHAINS_RESOURCE_IDS,\n      environment: \"production\",\n      productionUrl: env.PUBLIC_SUBGRAPHS_PRODUCTION_URL,\n    },\n  ],\n});\n```\n\nYou can use environment variables, hard-coded values, or a combination of both. Adjust the configuration according to your project's needs.\n\nThis file uses the `generateCodegenConfig` function from our package to create the configuration for @graphql-codegen/cli.\n\n### 2. Run CodeGen\n\nAdd a script to your `package.json` to run the code generation:\n\n```json\n{\n  \"scripts\": {\n    \"subgraph-codegen\": \"graphql-codegen --config ./src/subgraphs/codegen.ts\"\n  }\n}\n```\n\nNow you can generate your GraphQL clients by running:\n\n```bash\npnpm run subgraph-codegen\n```\n\n### 3. Consume the queries\n\nYou can see a how it's been used in the [dAppBooster Landing Page](https://github.com/BootNodeDev/dAppBoosterLandingPage).\n\nAnd for further information refer to the [subgraph documentation](https://github.com/BootNodeDev/dAppBoosterLandingPage/blob/main/SUBGRAPHS.md).\n\n## Configuration Options\n\nThe `PackageConfig` interface accepts the following options for each subgraph:\n\n- `apiKey`: Your subgraph API key.\n- `chainsResourceIds`: A string of comma-separated `\u003cchainId\u003e:\u003csubgraphId\u003e:\u003cresourceId\u003e`.\n  - i.e.: `137:uniswap:BvYimJ6vCLkk63oWZy7WB5cVDTVVMugUAF35RAUZpQXE,8453:aave:GQFbb95cE6d8mV989mL5figjaGaKCQB3xqYrr1bRyXqF`\n- `developmentUrl`: The URL for the development environment.\n- `productionUrl`: The URL for the production environment.\n- `environment`: Either 'development' or 'production'.\n- `queriesDirectory`: The directory where your GraphQL queries are located.\n  - default: `./src/subgraphs/queries`\n- `destinationDirectory`: The directory where your typed queries will be generated.\n  - defult: `./src/subgraphs/gql`\n\n## Adding Multiple Subgraphs\n\nYou can configure multiple subgraphs by adding more objects to the `subgraphs` array in your configuration:\n\n```typescript\nexport default generateCodegenConfig({\n  subgraphs: [\n    {\n      // First subgraph configuration\n    },\n    {\n      // Second subgraph configuration\n    },\n    // Add more as needed\n  ],\n});\n```\n\n## Generated Files\n\nThe package will generate GraphQL clients in the `src/subgraphs/gql/` directory, organized by subgraph ID.\n\n## Customization\n\nIf you need to customize the generation process further, you can modify the `codegen.ts` file. The package is designed to be flexible, allowing you to define configurations in the way that best suits your project structure and requirements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbootnodedev%2Fdb-subgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbootnodedev%2Fdb-subgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbootnodedev%2Fdb-subgraph/lists"}