Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
codegen-prismic-fetch
Advanced tools
A customFetch implementation for using @graphql-codegen with Prismic.io GraphQL APIs
Readme
A customFetch
implementation for using GraphQL Code Generator with Prismic CMS
This package helps you connect an existing GraphQL Code Generator setup to an existing Prismic CMS endpoint.
If you're not familiar with graphql-codegen
, follow the GraphQL Code Generator getting started guide 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.
npm i --save codegen-prismic-fetch
Or with yarn
yarn add codegen-prismic-fetch
Add a customFetch
to your codegen.yml
:
customFetch: codegen-prismic-fetch
See the codegen docs for details
on customFetch
usage.
If your API is private you'll need to specify an access token. You can do this in any of three ways:
PRISMIC_ACCESS_TOKEN
environment variableaccess_token
in your codegen.yml
schema URL: schema: "https://[your-repo-name].cdn.prismic.io/graphql?access_token=YOUR_TOKEN"
Authorization
header under schema
in your codegen.yml
. Make sure to include the prefix Token
, eg:schema:
https://[your-repo-name].cdn.prismic.io/graphql:
headers:
Authorization: Token YOUR_TOKEN
Setting customFetch
globally
customFetch: "codegen-prismic-fetch"
schema: https://[your-repo-name].cdn.prismic.io/graphql
Setting customFetch
under the schema
schema:
https://[your-repo-name].cdn.prismic.io/graphql:
customFetch: "codegen-prismic-fetch"
With an access token
schema:
https://[your-repo-name].cdn.prismic.io/graphql:
customFetch: "codegen-prismic-fetch"
headers:
Authorization: Token YOUR_TOKEN
Prismic has an unusual requirement which makes this library necessary - before making a graphql query we must make a call to
the REST API to find the identifier of the current "master" ref, and then we must pass it along in any graphql query
by setting the Prismic-ref
HTTP header. This library infers the API endpoint from your graphql endpoint, performs a
fetch
to get your master ref, and then adds that into codegen's graphql introspection queries.
Prismic also requires all queries to use the GET
method. You can specify this with codegen's method: GET
option,
but that's not necessary when using this library - we effectively set it for you by transforming all requests to GET
requests.
FAQs
A customFetch implementation for using @graphql-codegen with Prismic.io GraphQL APIs
The npm package codegen-prismic-fetch receives a total of 754 weekly downloads. As such, codegen-prismic-fetch popularity was classified as not popular.
We found that codegen-prismic-fetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.