craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Pending entries cause incremental updates to fail #30

Closed kara-todd closed 3 years ago

kara-todd commented 3 years ago

Description

We have been experiencing intermittent failures with our builds. (See craftcms/gatsby-helper#13 for context and details.) Part of the issue was resolved by changes to gatsby-helper. However, the issue persisted and I was able to track it down to occurring only on incremental builds which had a pending entry.

PR and details incoming...

Steps to reproduce

Suggestion: set a resolution to use gatsby-graphql-source-toolkit@2.0.1. This will give better error reporting.

  1. Run gatsby build to ensure a cache is built. This will trigger an incremental build on the next step.
  2. Create a "pending" status entry. (i.e. It must have a future publish date but be published.)
  3. Run gatsby build again. This time it should fail with Error: Node "[entry_type_from_step2]" with id "{ __typename: '[entry_type_from_step2]', id: '[entry_id_from_step2]', siteId: '1' }" is nullish.
andris-sevcenko commented 3 years ago

Okay, I fixed this. I Will see if we can publish a new version today.

moacode commented 3 years ago

Is this related to the following error by any chance? I have to clear cache and rebuild intermittently to get past it as well. If it's not, I'll create a new issue and try and track down what's going on.

Screen Shot 2021-05-19 at 8 46 02 PM
andris-sevcenko commented 3 years ago

@thejoshsmith I don't think so, no. Can you please open a new issue and also post a list of Craft plugins you have installed there, as well?

kara-todd commented 3 years ago

Thanks @andris-sevcenko can we get the fix integrated into both the 1.x and 2.x branches? It doesn't seem to have any conflicts.

andris-sevcenko commented 3 years ago

@kara-todd the fix is in those branches already, just have to cut a release. Will look into that!

andris-sevcenko commented 3 years ago

@kara-todd we'll get out a release today!

andris-sevcenko commented 3 years ago

v1 and v2 both have been released with a fix for this. Thanks again!

kara-todd commented 3 years ago

@andris-sevcenko I ran into a bug with this update where the status parameter caused another entry type to fail. I think it was "Assets" but I can't remember...

I hacked a quick fix to just filter it to entry types: https://github.com/kara-todd/gatsby-source-craft/commit/3fab65e587c22544a02a1e9363529a0e02618beb

andris-sevcenko commented 3 years ago

@kara-todd That's.. strange. How did it fail? I'm not questioning, just looking for more information, so I can make a solid fix for it.

kara-todd commented 3 years ago

@andris-sevcenko I've pasted the error message I received below. In this particular case, LIST_pageImages_Asset but I had this fail on another site with a different asset type.

I think this is because status is not a valid Input parameter for the AssetInterface type in graphQL. See below screenshot from the schema explorer.

Screen Shot 2021-05-25 at 5 50 22 PM
"gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

Failed to execute query LIST_pageImages_Asset.
Errors:
Unknown argument "status" on field "asset" of type "Query".

  468 |     if (remoteConfigVersion !== localConfigVersion || !localContentUpdateTime) {
  469 |         reporter.info("Cached content is unavailable or outdated, sourcing _all_ nodes.");
> 470 |         await sourceAllNodes(config);
      |         ^
  471 |     }
  472 |     else {
  473 |         reporter.info(`Craft config version has not changed since last sourcing. Checking for content changes since "${localContentUpdateTime}".`);

File: node_modules/gatsby-source-craft/gatsby-node.js:470:9

  Error: Failed to execute query LIST_pageImages_Asset.
  Errors:
  Unknown argument "status" on field "asset" of type "Query".

  - paginate.ts:60 Object.paginate
    [app]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/paginate.ts:60:13

  - task_queues.js:93 processTicksAndRejections
    internal/process/task_queues.js:93:5

  - fetch-lists.ts:61 fetchNodeList
    [app]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lists.ts:61:20

  - fetch-lists.ts:36 Object.fetchAllNodes
    [app]/[gatsby-graphql-source-toolkit]/src/source-nodes/fetch-nodes/fetch-lists.ts:36:24

  - create-nodes.ts:13 Object.createNodes
    [app]/[gatsby-graphql-source-toolkit]/src/source-nodes/node-actions/create-nodes.ts:13:20

  - async Promise.all

  - source-all-nodes.ts:20 sourceAllNodes
    [app]/[gatsby-graphql-source-toolkit]/src/source-nodes/source-all-nodes.ts:20:3

  - gatsby-node.js:470 Object.exports.sourceNodes
    [app]/[gatsby-source-craft]/gatsby-node.js:470:9

  - api-runner-node.js:434 runAPI
    [app]/[gatsby]/src/utils/api-runner-node.js:434:16
andris-sevcenko commented 3 years ago

Ah, rats.

I looked at the methods available on the element query, not GraphQL one. Okay, okay. I'll patch this.

andris-sevcenko commented 3 years ago

@kara-todd Just fixed it on Craft itself.