{"id":14976225,"url":"https://github.com/robhogan/codegen-prismic-fetch","last_synced_at":"2025-03-30T00:30:30.769Z","repository":{"id":46603379,"uuid":"333195977","full_name":"robhogan/codegen-prismic-fetch","owner":"robhogan","description":"A `customFetch` implementation for using https://graphql-code-generator.com with https://prismic.io","archived":false,"fork":false,"pushed_at":"2021-10-05T10:45:33.000Z","size":90,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T08:09:10.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/robhogan.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}},"created_at":"2021-01-26T19:37:23.000Z","updated_at":"2024-01-24T04:16:39.000Z","dependencies_parsed_at":"2022-09-03T08:01:46.125Z","dependency_job_id":null,"html_url":"https://github.com/robhogan/codegen-prismic-fetch","commit_stats":null,"previous_names":["rh389/codegen-prismic-fetch"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhogan%2Fcodegen-prismic-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhogan%2Fcodegen-prismic-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhogan%2Fcodegen-prismic-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhogan%2Fcodegen-prismic-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robhogan","download_url":"https://codeload.github.com/robhogan/codegen-prismic-fetch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"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-09-24T13:53:32.197Z","updated_at":"2025-03-30T00:30:30.323Z","avatar_url":"https://github.com/robhogan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codegen-prismic-fetch\n\n[![npm version](https://badge.fury.io/js/codegen-prismic-fetch.svg)](https://badge.fury.io/js/codegen-prismic-fetch)\n\nA `customFetch` implementation for using [GraphQL Code Generator](https://graphql-code-generator.com/) with [Prismic CMS](https://prismic.io)\n\n## Prerequisites\n\nThis package helps you connect an existing GraphQL Code Generator setup to an existing Prismic CMS endpoint.\n\nIf you're not familiar with `graphql-codegen`, follow the [GraphQL Code Generator getting started guide](https://www.graphql-code-generator.com/docs/getting-started/installation) to set up `graphql-codegen` (and `graphql` itself) with your npm/yarn-based app, and then come back here to get `graphql-codegen` talking to your Prismic endpoint.\n\n## Usage\n\n```shell\nnpm i --save codegen-prismic-fetch\n```\n\n**Or** with yarn\n\n```shell\nyarn add codegen-prismic-fetch\n```\n\nAdd a `customFetch` to your `codegen.yml`:\n\n```yaml\ncustomFetch: codegen-prismic-fetch\n```\n\nSee [the codegen docs](https://graphql-code-generator.com/docs/getting-started/schema-field/#customfetch) for details\non `customFetch` usage.\n\n## Authentication\n\nIf your API is private you'll need to specify an access token. You can do this in any of three ways:\n\n- Set the `PRISMIC_ACCESS_TOKEN` environment variable\n- Include `access_token` in your `codegen.yml` schema URL: `schema: \"https://[your-repo-name].cdn.prismic.io/graphql?access_token=YOUR_TOKEN\"`\n- Include an `Authorization` header under `schema` in your `codegen.yml`. Make sure to include the prefix `Token `, eg:\n\n```yaml\nschema:\n  https://[your-repo-name].cdn.prismic.io/graphql:\n    headers:\n      Authorization: Token YOUR_TOKEN\n```\n\n## Example\n\nSetting `customFetch` globally\n\n```yaml\ncustomFetch: \"codegen-prismic-fetch\"\nschema: https://[your-repo-name].cdn.prismic.io/graphql\n```\n\nSetting `customFetch` under the `schema`\n\n```yaml\nschema:\n  https://[your-repo-name].cdn.prismic.io/graphql:\n    customFetch: \"codegen-prismic-fetch\"\n```\n\nWith an access token\n\n```yaml\nschema:\n  https://[your-repo-name].cdn.prismic.io/graphql:\n    customFetch: \"codegen-prismic-fetch\"\n    headers:\n      Authorization: Token YOUR_TOKEN\n```\n\n## How does it work?\n\nPrismic has an unusual requirement which makes this library necessary - before making a graphql query we must make a call to\nthe REST API to find the identifier of the current \"master\" ref, and then we must pass it along in any graphql query\nby setting the `Prismic-ref` HTTP header. This library infers the API endpoint from your graphql endpoint, performs a\n`fetch` to get your master ref, and then adds that into codegen's graphql introspection queries.\n\nPrismic also requires all queries to use the `GET` method. You can specify this with codegen's `method: GET` option,\nbut that's not necessary when using this library - we effectively set it for you by transforming all requests to `GET`\nrequests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhogan%2Fcodegen-prismic-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobhogan%2Fcodegen-prismic-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhogan%2Fcodegen-prismic-fetch/lists"}