{"id":16265948,"url":"https://github.com/robinck/graphql-codegen-static-data","last_synced_at":"2026-02-14T20:36:46.133Z","repository":{"id":256914493,"uuid":"844417942","full_name":"RobinCK/graphql-codegen-static-data","owner":"RobinCK","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-13T08:37:43.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-08T20:25:37.205Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobinCK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-08-19T08:09:26.000Z","updated_at":"2024-09-13T23:18:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"cffa6805-aa55-4c24-9a20-31102fd378b8","html_url":"https://github.com/RobinCK/graphql-codegen-static-data","commit_stats":null,"previous_names":["robinck/graphql-codegen-static-data"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RobinCK/graphql-codegen-static-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fgraphql-codegen-static-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fgraphql-codegen-static-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fgraphql-codegen-static-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fgraphql-codegen-static-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinCK","download_url":"https://codeload.github.com/RobinCK/graphql-codegen-static-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinCK%2Fgraphql-codegen-static-data/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29455362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-10T17:21:13.307Z","updated_at":"2026-02-14T20:36:46.119Z","avatar_url":"https://github.com/RobinCK.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# graphql-codegen-static-data\n\n[![npm version](https://badge.fury.io/js/graphql-codegen-static-data.svg)](https://badge.fury.io/js/graphql-codegen-static-data)\n\nA plugin for [GraphQL Code Generator](https://the-guild.dev/graphql/codegen) that generates static data by executing GraphQL queries against your API and saving the results as static files. This is useful for projects that require pre-fetched data to improve performance or work in offline mode.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n- [Examples](#examples)\n- [Notes](#notes)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Introduction\n\n`graphql-codegen-static-data` allows you to generate static data by executing GraphQL queries against your API and saving the results to files. This is especially useful for static sites or applications that need pre-fetched data.\n\n## Installation\n\nInstall the plugin using npm:\n\n```bash\nnpm install --save-dev graphql-codegen-static-data\n```\n\nOr using Yarn:\n\n```bash\nyarn add --dev graphql-codegen-static-data\n```\n\n## Usage\n\nAdd the plugin to your GraphQL Codegen configuration and set it up to execute the required queries:\n\n```yaml\ngenerates:\n  ./src/graphql/generatedStatic.ts:\n    plugins:\n      - 'graphql-codegen-static-data'\n    config:\n      url: 'http://localhost:3000/graphql'\n      fetch:\n        - path: 'data.posts'\n          query: |\n            query Posts {\n              posts {\n                id\n                title\n                content\n              }\n            }\n```\n\n## Configuration\n\nThe plugin supports the following configuration options:\n\n- **url**: The URL of your GraphQL API where the queries will be sent.\n- **fetch**: An array of objects containing settings for each query:\n  - **path**: The JSON path to the data in the response you want to save. The `lodash.get` syntax is used to access this data.\n  - **query**: The GraphQL query to be executed.\n\n### Configuration Details\n\n#### url\n\nThe URL of your GraphQL API. For example: `https://api.example.com/graphql`.\n\n#### fetch\n\nAn array of objects, each containing:\n\n- **path**: The path to the data in the response that you want to extract and save. This is a JSON path using `lodash.get` syntax. For example: `data.posts`.\n- **query**: The GraphQL query as a string.\n\n#### Example\n\n```yaml\ngenerates:\n  ./src/graphql/generatedStatic.ts:\n    plugins:\n      - 'graphql-codegen-static-data'\n    config:\n      url: 'http://localhost:3000/graphql'\n      fetch:\n        - path: 'data.posts'\n          query: |\n            query GetPosts {\n              posts {\n                id\n                title\n                content\n              }\n            }\n        - path: 'data.users'\n          query: |\n            query GetUsers {\n              users {\n                id\n                username\n              }\n            }\n```\n\nIn this example, the plugin will execute two queries against your GraphQL API:\n\n1. **GetPosts**: The result of the query will be saved from the path `data.posts` in the response. These data will be available in the generated file at that path.\n2. **GetUsers**: Similarly, data from `data.users` will be saved.\n\n## Examples\n\n### Generating Static Data for Posts\n\n```yaml\ngenerates:\n  ./src/graphql/postsData.ts:\n    plugins:\n      - 'graphql-codegen-static-data'\n    config:\n      url: 'https://api.example.com/graphql'\n      fetch:\n        - path: 'data.posts'\n          query: |\n            query GetPosts {\n              posts {\n                id\n                title\n                content\n                author {\n                  id\n                  name\n                }\n              }\n            }\n```\n\nIn this example, data from `data.posts` in the response will be extracted and saved in the generated file.\n\n### Generating Static Data for Comments\n\n```yaml\ngenerates:\n  ./src/graphql/commentsData.ts:\n    plugins:\n      - 'graphql-codegen-static-data'\n    config:\n      url: 'https://api.example.com/graphql'\n      fetch:\n        - path: 'data.comments'\n          query: |\n            query GetComments {\n              comments {\n                id\n                text\n                postId\n              }\n            }\n```\n\nData from `data.comments` will be extracted and saved.\n\n## Notes\n\n- **lodash.get**: The plugin uses the `get` function from the `lodash` library to access the desired data in the response. This allows you to easily specify the path to the data in nested structures.\n\n- **JSON Path**: The path syntax is the same as in `lodash.get`. For example, `data.posts[0].title` retrieves the title of the first post.\n\n## Contributing\n\nContributions are welcome! Please read the [contribution guidelines](CONTRIBUTING.md) before getting started.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinck%2Fgraphql-codegen-static-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinck%2Fgraphql-codegen-static-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinck%2Fgraphql-codegen-static-data/lists"}