Skip to content

Commit d719435

Browse files
authored
feat: add concurrenecy override (#201)
* feat: add concurrenecy override * feat: rename concurrency config option
1 parent 0dfc8e8 commit d719435

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fragment User on User {
2+
stage
3+
remoteId: id
4+
createdAt
5+
updatedAt
6+
publishedAt
7+
name
8+
picture
9+
kind
10+
isActive
11+
}

gatsby-source-graphcms/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ module.exports = {
7373
| --------------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7474
| `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). |
7575
| `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). |
76-
| `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. |
76+
| `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. |
7777
| `downloadLocalImages` | Boolean _(Default: `false`)_ | Download and cache GraphCMS image assets in your Gatsby project. [Learn more](#downloading-local-image-assets). |
7878
| `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). |
7979
| `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. |
8080
| `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). |
8181
| `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). |
82+
| `queryConcurrency` | Integer _(Default: 10)_ | The number of promises ran at once when executing queries. |
8283

8384
## Features
8485

@@ -190,7 +191,7 @@ Use the `gatsbyImageData` resolver on your `GraphCMS_Asset` nodes.
190191
| `quality` | Int | The default image quality generated. This is overridden by any format-specific options. |
191192
| `sizes` | String | [The `<img> sizes` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes), passed to the img tag. This describes the display size of the image, and does not affect generated images. You are only likely to need to change this if your are using full width images that do not span the full width of the screen. |
192193
| `width` | Int | Change the size of the image. |
193-
| `placeholder` | `NONE`/`BLURRED`/`DOMINANT_COLOR`/`TRACED_SVG` | Choose the style of temporary image shown while the full image loads. |
194+
| `placeholder` | `NONE`/`BLURRED`/`DOMINANT_COLOR`/`TRACED_SVG` | Choose the style of temporary image shown while the full image loads. |
194195

195196
**NOTE**: `gatsby-plugin-sharp` needs to be listed as a dependency on your project if you plan to use placeholder `TRACED_SVG` or `DOMINANT_COLOR`.
196197

@@ -359,13 +360,15 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
359360
<details>
360361
<summary>"endpoint" is required</summary>
361362

362-
If you are using environment variables, make sure to include `require("dotenv").config();` inside your `gatsby-config.js`.
363-
364-
If it's already included, make sure you have your ENV variable added to `.env`, or `.env.local` without spaces.
363+
If you are using environment variables, make sure to include `require("dotenv").config();` inside your `gatsby-config.js`.
364+
365+
If it's already included, make sure you have your ENV variable added to `.env`, or `.env.local` without spaces.
366+
365367
</details>
366368

367369
<details>
368370
<summary>"message": "not allowed"</summary>
369371

370-
This error occurs most likely if your token doesn't have access to the `PUBLISHED` content stage. Configure your token to also access `PUBLISHED`, or specify `stages: ["DRAFT"]` to the options inside `gatsby-config.js`.
372+
This error occurs most likely if your token doesn't have access to the `PUBLISHED` content stage. Configure your token to also access `PUBLISHED`, or specify `stages: ["DRAFT"]` to the options inside `gatsby-config.js`.
373+
371374
</details>

gatsby-source-graphcms/src/gatsby-node.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ export function pluginOptionsSchema({ Joi }) {
6969
`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`
7070
)
7171
.default(`GraphCMS_`),
72+
concurrency: Joi.number()
73+
.integer()
74+
.min(1)
75+
.default(10)
76+
.description(`The number of promises to run at one time.`),
7277
})
7378
}
7479

7580
const createSourcingConfig = async (
7681
gatsbyApi,
77-
{ endpoint, fragmentsPath, locales, stages, token, typePrefix }
82+
{ endpoint, fragmentsPath, locales, stages, token, typePrefix, concurrency }
7883
) => {
7984
const execute = async ({ operationName, query, variables = {} }) => {
8085
const { reporter } = gatsbyApi
@@ -199,7 +204,7 @@ const createSourcingConfig = async (
199204
return {
200205
gatsbyApi,
201206
schema,
202-
execute: wrapQueryExecutorWithQueue(execute, { concurrency: 10 }),
207+
execute: wrapQueryExecutorWithQueue(execute, { concurrency }),
203208
gatsbyTypePrefix: typePrefix,
204209
gatsbyNodeDefs: buildNodeDefinitions({ gatsbyNodeTypes, documents }),
205210
}

0 commit comments

Comments
 (0)