diff --git a/.all-contributorsrc b/.all-contributorsrc
index 13cd9e3..b8aa3f9 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -46,7 +46,7 @@
],
"contributorsPerLine": 7,
"projectName": "gatsby-source-graphcms",
- "projectOwner": "GraphCMS",
+ "projectOwner": "hygraph",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true
diff --git a/LICENSE b/LICENSE
index d2b7c2e..7767a7f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2021 GraphCMS
+Copyright (c) 2022 GraphCMS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/demo/gatsby-config.js b/demo/gatsby-config.js
index 3b440d3..14b7ad2 100644
--- a/demo/gatsby-config.js
+++ b/demo/gatsby-config.js
@@ -11,8 +11,8 @@ module.exports = {
options: {
buildMarkdownNodes: true,
endpoint:
- process.env.GRAPHCMS_ENDPOINT ||
- 'https://api-eu-central-1.graphcms.com/v2/ckclvjtet0f0901z69og3f3gm/master',
+ process.env.HYGRAPH_ENDPOINT ||
+ 'https://api-eu-central-1.hygraph.com/v2/ckclvjtet0f0901z69og3f3gm/master',
locales: ['en', 'de'],
stages: ['DRAFT', 'PUBLISHED'],
},
diff --git a/gatsby-source-graphcms/README.md b/gatsby-source-graphcms/README.md
index d9e3d69..fa27b00 100644
--- a/gatsby-source-graphcms/README.md
+++ b/gatsby-source-graphcms/README.md
@@ -1,5 +1,5 @@
gatsby-source-graphcms
-The official Gatsby source plugin for GraphCMS projects
+The official Gatsby source plugin for Hygraph projects
@@ -8,18 +8,18 @@
-
+
-
-
+
+
- Demo • gatsby-starter-graphcms-blog • Join us on Slack • Login to GraphCMS • @GraphCMS
+ Demo • gatsby-starter-hygraph-blog • Join us on Slack • Login to Hygraph • @hygraphcom
## Installation
@@ -32,7 +32,7 @@ yarn add gatsby-source-graphcms gatsby-plugin-image
## Configuration
-> We recommend using environment variables with your GraphCMS `token` and `endpoint` values. You can learn more about using environment variables with Gatsby [here](https://www.gatsbyjs.org/docs/environment-variables).
+> We recommend using environment variables with your Hygraph `token` and `endpoint` values. You can learn more about using environment variables with Gatsby [here](https://www.gatsbyjs.org/docs/environment-variables).
### Basic
@@ -43,7 +43,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
},
},
],
@@ -52,7 +52,7 @@ module.exports = {
### Authorization
-You can also provide an auth token using the `token` configuration key. This is necessary if your GraphCMS project is **not** publicly available, or you want to scope access to a specific content stage (i.e. draft content).
+You can also provide an auth token using the `token` configuration key. This is necessary if your Hygraph project is **not** publicly available, or you want to scope access to a specific content stage (i.e. draft content).
```js
// gatsby-config.js
@@ -61,8 +61,8 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
- token: process.env.GRAPHCMS_TOKEN,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
+ token: process.env.HYGRAPH_TOKEN,
},
},
],
@@ -71,30 +71,41 @@ module.exports = {
### Options
-| Key | Type | Description |
-| --------------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `endpoint` | String (**required**) | The endpoint URL for the GraphCMS project. This can be found in the [project settings UI](https://graphcms.com/docs/guides/concepts/apis#working-with-apis). |
-| `token` | String | If your GraphCMS project is **not** publicly accessible, you will need to provide a [Permanent Auth Token](https://graphcms.com/docs/reference/authorization) to correctly authorize with the API. You can learn more about creating and managing API tokens [here](https://graphcms.com/docs/guides/concepts/apis#working-with-apis). |
-| `typePrefix` | String _(Default: `GraphCMS_`)\_ | The string by which every generated type name is prefixed with. For example, a type of `Post` in GraphCMS would become `GraphCMS_Post` by default. If using multiple instances of the source plugin, you **must** provide a value here to prevent type conflicts. |
-| `downloadLocalImages` | Boolean _(Default: `false`)_ | Download and cache GraphCMS image assets in your Gatsby project. [Learn more](#downloading-local-image-assets). |
-| `buildMarkdownNodes` | Boolean _(Default: `false`)_ | Build markdown nodes for all [`RichText`](https://graphcms.com/docs/reference/fields/rich-text) fields in your GraphCMS schema. [Learn more](#using-markdown-nodes). |
-| `fragmentsPath` | String _(Default: `graphcms-fragments`)_ | The local project path where generated query fragments are saved. This is relative to your current working directory. If using multiple instances of the source plugin, you **must** provide a value here to prevent type and/or fragment conflicts. |
-| `locales` | String _(Default: `['en']`)_ | An array of locale key strings from your GraphCMS project. [Learn more](#querying-localised-nodes). You can read more about working with localisation in GraphCMS [here](https://graphcms.com/docs/guides/concepts/i18n). |
-| `stages` | String _(Default: `['PUBLISHED']`)_ | An array of Content Stages from your GraphCMS project. [Learn more](#querying-from-content-stages). You can read more about using Content Stages [here](https://graphcms.com/guides/working-with-content-stages). |
-| `queryConcurrency` | Integer _(Default: 10)_ | The number of promises ran at once when executing queries. |
+| Key | Type | Description |
+| --------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `endpoint` | String (**required**) | The endpoint URL for the Hygraph project. This can be found in the [project settings UI](https://hygraph.com/docs/guides/concepts/apis#working-with-apis). |
+| `token` | String | If your Hygraph project is **not** publicly accessible, you will need to provide a [Permanent Auth Token](https://hygraph.com/docs/reference/authorization) to correctly authorize with the API. You can learn more about creating and managing API tokens [here](https://hygraph.com/docs/guides/concepts/apis#working-with-apis). |
+| `typePrefix` | String _(Default: `GraphCMS_`)\_ | The string by which every generated type name is prefixed with. For example, a type of `Post` in Hygraph would become `GraphCMS_Post` by default. If using multiple instances of the source plugin, you **must** provide a value here to prevent type conflicts. |
+| `downloadLocalImages` | Boolean _(Default: `false`)_ | Download and cache Hygraph image assets in your Gatsby project. [Learn more](#downloading-local-image-assets). |
+| `buildMarkdownNodes` | Boolean _(Default: `false`)_ | Build markdown nodes for all [`RichText`](https://hygraph.com/docs/reference/fields/rich-text) fields in your Hygraph schema. [Learn more](#using-markdown-nodes). |
+| `fragmentsPath` | String _(Default: `graphcms-fragments`)_ | The local project path where generated query fragments are saved. This is relative to your current working directory. If using multiple instances of the source plugin, you **must** provide a value here to prevent type and/or fragment conflicts. |
+| `locales` | String _(Default: `['en']`)_ | An array of locale key strings from your Hygraph project. [Learn more](#querying-localised-nodes). You can read more about working with localisation in Hygraph [here](https://hygraph.com/docs/guides/concepts/i18n). |
+| `stages` | String _(Default: `['PUBLISHED']`)_ | An array of Content Stages from your Hygraph project. [Learn more](#querying-from-content-stages). You can read more about using Content Stages [here](https://hygraph.com/guides/working-with-content-stages). |
+| `queryConcurrency` | Integer _(Default: 10)_ | The number of promises ran at once when executing queries. |
## Features
-- [Querying localised nodes](#querying-localised-nodes)
-- [Querying from content stages](#querying-from-content-stages)
-- [Usage with `gatsby-plugin-image`](#usage-with-gatsby-plugin-image)
-- [Downloading local image assets](#downloading-local-image-assets)
-- [Using markdown nodes](#using-markdown-nodes)
-- [Working with query fragments](#working-with-query-fragments)
+- [Installation](#installation)
+- [Configuration](#configuration)
+ - [Basic](#basic)
+ - [Authorization](#authorization)
+ - [Options](#options)
+- [Features](#features)
+ - [Querying localised nodes](#querying-localised-nodes)
+ - [Querying from content stages](#querying-from-content-stages)
+ - [Usage with `gatsby-plugin-image`](#usage-with-gatsby-plugin-image)
+ - [`gatsbyImageData` resolver arguments](#gatsbyimagedata-resolver-arguments)
+ - [Downloading local image assets](#downloading-local-image-assets)
+ - [Using markdown nodes](#using-markdown-nodes)
+ - [Usage with `gatsby-plugin-mdx`](#usage-with-gatsby-plugin-mdx)
+ - [Working with query fragments](#working-with-query-fragments)
+ - [Modifying query fragments](#modifying-query-fragments)
+- [Contributors](#contributors)
+- [FAQs](#faqs)
### Querying localised nodes
-If using GraphCMS localisation, this plugin provides support to build nodes for all provided locales.
+If using Hygraph localisation, this plugin provides support to build nodes for all provided locales.
Update your plugin configuration to include the `locales` key.
@@ -105,7 +116,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
locales: ['en', 'de'],
},
},
@@ -125,13 +136,13 @@ To query for nodes for a specific locale, use the `filter` query argument.
}
```
-Check out the [demo source](https://github.com/GraphCMS/gatsby-source-graphcms/tree/main/demo) for an example of a localisation implementation.
+Check out the [demo source](https://github.com/hygraph/gatsby-source-graphcms/tree/main/demo) for an example of a localisation implementation.
### Querying from content stages
This plugin provides support to build nodes for entries from multiple Content Stages.
-The provided Content Stages **must** be accessible according to the configuration of your project's [API access](https://graphcms.com/docs/authorization). If providing a `token`, then that [Permanent Auth Token](https://graphcms.com/docs/authorization#permanent-auth-tokens) must have permission to query data from all provided Content Stages.
+The provided Content Stages **must** be accessible according to the configuration of your project's [API access](https://hygraph.com/docs/authorization). If providing a `token`, then that [Permanent Auth Token](https://hygraph.com/docs/authorization#permanent-auth-tokens) must have permission to query data from all provided Content Stages.
The example below assumes that both the `DRAFT` and `PUBLISHED` stages are publicly accessible.
@@ -142,7 +153,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
stages: ['DRAFT', 'PUBLISHED'],
},
},
@@ -166,7 +177,7 @@ To query for nodes from a specific Content Stage, use the `filter` query argumen
> Requires [`gatsby-plugin-image`](https://www.gatsbyjs.com/plugins/gatsby-plugin-image) as a project dependency.
-This source plugin supports `gatsby-plugin-image` for responsive, high performance GraphCMS images direct from our CDN.
+This source plugin supports `gatsby-plugin-image` for responsive, high performance Hygraph images direct from our CDN.
Use the `gatsbyImageData` resolver on your `GraphCMS_Asset` nodes.
@@ -201,7 +212,7 @@ For more information on using `gatsby-plugin-image`, please see the [documentati
### Downloading local image assets
-If you prefer, the source plugin also provides the option to download and cache GraphCMS assets in your Gatsby project.
+If you prefer, the source plugin also provides the option to download and cache Hygraph assets in your Gatsby project.
To enable this, add `downloadLocalImages: true` to your plugin configuration.
@@ -212,7 +223,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
downloadLocalImages: true,
},
},
@@ -238,7 +249,7 @@ This adds a `localFile` field to the `GraphCMS_Asset` type which resolves to the
### Using markdown nodes
-This source plugin provides the option to build markdown nodes for all `RichText` fields in your GraphCMS schema, which in turn can be used with [MDX](https://mdxjs.com).
+This source plugin provides the option to build markdown nodes for all `RichText` fields in your Hygraph schema, which in turn can be used with [MDX](https://mdxjs.com).
To enable this, add `buildMarkdownNodes: true` to your plugin configuration.
@@ -249,7 +260,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
buildMarkdownNodes: true,
},
},
@@ -259,11 +270,11 @@ module.exports = {
Enabling this option adds a `markdownNode` nested field to all `RichText` fields on the generated Gatsby schema.
-You will need to rebuild your `graphcms-fragments` if you enable embeds on a Rich Text field, or you add/remove additional fields to your GraphCMS schema.
+You will need to rebuild your `graphcms-fragments` if you enable embeds on a Rich Text field, or you add/remove additional fields to your Hygraph schema.
#### Usage with `gatsby-plugin-mdx`
-These newly built nodes can be used with [`gatsby-plugin-mdx`](https://www.gatsbyjs.org/packages/gatsby-plugin-mdx) to render markdown from GraphCMS.
+These newly built nodes can be used with [`gatsby-plugin-mdx`](https://www.gatsbyjs.org/packages/gatsby-plugin-mdx) to render markdown from Hygraph.
Once installed, you will be able to query for `MDX` fields using a query similar to the one below.
@@ -284,7 +295,7 @@ Once installed, you will be able to query for `MDX` fields using a query similar
}
```
-Check out the [demo source](https://github.com/GraphCMS/gatsby-source-graphcms/tree/main/demo) for an example of a full MDX implementation.
+Check out the [demo source](https://github.com/hygraph/gatsby-source-graphcms/tree/main/demo) for an example of a full MDX implementation.
### Working with query fragments
@@ -299,7 +310,7 @@ module.exports = {
{
resolve: 'gatsby-source-graphcms',
options: {
- endpoint: process.env.GRAPHCMS_ENDPOINT,
+ endpoint: process.env.HYGRAPH_ENDPOINT,
fragmentsPath: 'my-query-fragments',
},
},
@@ -309,7 +320,7 @@ module.exports = {
The generated fragments are then read from the project for subsequent builds. It is recommended that they are checked in to version control for your project.
-Should you make any changes or additions to your GraphCMS schema, you will need to update the query fragments accrdingly. Alternatively they will be regnerated on a subsequent build after removing the directory from your project.
+Should you make any changes or additions to your Hygraph schema, you will need to update the query fragments accrdingly. Alternatively they will be regnerated on a subsequent build after removing the directory from your project.
#### Modifying query fragments
@@ -326,7 +337,7 @@ fragment Industry on Industry {
}
```
-Field arguments cannot be read by Gatsby from the GraphCMS schema. Instead we must alias any required usages as aliased fields. In this example, the `featuredCaseStudy` field would then be available in our Gatsby queries:
+Field arguments cannot be read by Gatsby from the Hygraph schema. Instead we must alias any required usages as aliased fields. In this example, the `featuredCaseStudy` field would then be available in our Gatsby queries:
```graphql
{
@@ -349,9 +360,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
diff --git a/gatsby-source-graphcms/package.json b/gatsby-source-graphcms/package.json
index b0c25e3..cb36bb9 100644
--- a/gatsby-source-graphcms/package.json
+++ b/gatsby-source-graphcms/package.json
@@ -1,7 +1,7 @@
{
"name": "gatsby-source-graphcms",
"version": "2.0.0",
- "description": "The official Gatsby source plugin for GraphCMS projects",
+ "description": "The official Gatsby source plugin for Hygraph projects",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir ./ --source-maps"
@@ -10,7 +10,7 @@
"data",
"gatsby",
"gatsby-plugin",
- "graphcms",
+ "hygraph",
"graphql",
"source"
],
diff --git a/gatsby-source-graphcms/src/gatsby-node.js b/gatsby-source-graphcms/src/gatsby-node.js
index d1956eb..9338982 100644
--- a/gatsby-source-graphcms/src/gatsby-node.js
+++ b/gatsby-source-graphcms/src/gatsby-node.js
@@ -29,17 +29,17 @@ export function pluginOptionsSchema({ Joi }) {
return Joi.object({
buildMarkdownNodes: Joi.boolean()
.description(
- `Build markdown nodes for all [RichText](https://graphcms.com/docs/reference/fields/rich-text) fields in your GraphCMS schema`
+ `Build markdown nodes for all [RichText](https://hygraph.com/docs/reference/fields/rich-text) fields in your Hygraph schema`
)
.default(false),
downloadLocalImages: Joi.boolean()
.description(
- `Download and cache GraphCMS image assets in your Gatsby project`
+ `Download and cache Hygraph image assets in your Gatsby project`
)
.default(false),
endpoint: Joi.string()
.description(
- `The endpoint URL for the GraphCMS project. This can be found in the [project settings UI](https://graphcms.com/docs/guides/concepts/apis#working-with-apis)`
+ `The endpoint URL for the Hygraph project. This can be found in the [project settings UI](https://hygraph.com/docs/guides/concepts/apis#working-with-apis)`
)
.required(),
fragmentsPath: Joi.string()
@@ -49,24 +49,24 @@ export function pluginOptionsSchema({ Joi }) {
.default(`graphcms-fragments`),
locales: Joi.array()
.description(
- `An array of locale key strings from your GraphCMS project. You can read more about working with localisation in GraphCMS [here](https://graphcms.com/docs/guides/concepts/i18n).`
+ `An array of locale key strings from your Hygraph project. You can read more about working with localisation in Hygraph [here](https://hygraph.com/docs/guides/concepts/i18n).`
)
.items(Joi.string())
.min(1)
.default(['en']),
stages: Joi.array()
.description(
- `An array of Content Stages from your GraphCMS project. You can read more about using Content Stages [here](https://graphcms.com/guides/working-with-content-stages).`
+ `An array of Content Stages from your Hygraph project. You can read more about using Content Stages [here](https://hygraph.com/guides/working-with-content-stages).`
)
.items(Joi.string())
.min(1)
.default(['PUBLISHED']),
token: Joi.string().description(
- `If your GraphCMS project is **not** publicly accessible, you will need to provide a [Permanent Auth Token](https://graphcms.com/docs/reference/authorization) to correctly authorize with the API. You can learn more about creating and managing API tokens [here](https://graphcms.com/docs/guides/concepts/apis#working-with-apis)`
+ `If your Hygraph project is **not** publicly accessible, you will need to provide a [Permanent Auth Token](https://hygraph.com/docs/reference/authorization) to correctly authorize with the API. You can learn more about creating and managing API tokens [here](https://hygraph.com/docs/guides/concepts/apis#working-with-apis)`
),
typePrefix: Joi.string()
.description(
- `The string by which every generated type name is prefixed with. For example, a type of Post in GraphCMS would become GraphCMS_Post by default. If using multiple instances of the source plugin, you **must** provide a value here to prevent type conflicts`
+ `The string by which every generated type name is prefixed with. For example, a type of Post in Hygraph would become GraphCMS_Post by default. If using multiple instances of the source plugin, you **must** provide a value here to prevent type conflicts`
)
.default(`GraphCMS_`),
queryConcurrency: Joi.number()
@@ -104,7 +104,7 @@ const createSourcingConfig = async (
if (!response.ok) {
return reportPanic(
1,
- 'Problem building GraphCMS nodes',
+ 'Problem building Hygraph nodes',
response.statusText,
reporter
)
@@ -116,7 +116,7 @@ const createSourcingConfig = async (
if (response.errors) {
return reportPanic(
2,
- 'Problem building GraphCMS nodes',
+ 'Problem building Hygraph nodes',
JSON.stringify(response.errors, null, 2),
reporter
)
@@ -127,7 +127,7 @@ const createSourcingConfig = async (
.catch((error) => {
return reportPanic(
3,
- 'Problem building GraphCMS nodes',
+ 'Problem building Hygraph nodes',
JSON.stringify(error, null, 2),
reporter
)
@@ -320,9 +320,13 @@ export async function onCreateNode(
if (
downloadLocalImages &&
node.remoteTypeName === 'Asset' &&
- ['image/png', 'image/jpg', 'image/jpeg', 'image/tiff', 'image/webp'].includes(
- node.mimeType
- )
+ [
+ 'image/png',
+ 'image/jpg',
+ 'image/jpeg',
+ 'image/tiff',
+ 'image/webp',
+ ].includes(node.mimeType)
) {
try {
const fileNode = await createRemoteFileNode({
@@ -398,7 +402,13 @@ function makeResolveGatsbyImageData(cache) {
options
) {
if (
- !['image/png', 'image/jpg', 'image/jpeg', 'image/tiff', 'image/webp'].includes(mimeType)
+ ![
+ 'image/png',
+ 'image/jpg',
+ 'image/jpeg',
+ 'image/tiff',
+ 'image/webp',
+ ].includes(mimeType)
) {
return null
}