relate-app / gatsby-source-strapi-graphql

A Gatsby source plugin for building websites using Strapi as a data source
BSD Zero Clause License
32 stars 9 forks source link

TypeError: Cannot read property 'reduce' of null #25

Open stevensystems opened 2 years ago

stevensystems commented 2 years ago

Description

When using strapi navigation plugin on strapi, I get the following error

 ERROR #11321  PLUGIN

"@relate-app/gatsby-source-strapi" threw an error while running the sourceNodes lifecycle:

Cannot read property 'match' of null

  32 |   const lastFetched = pluginOptions.cache !== false ? await cache.get(`timestamp`) : null;
  33 |   const { unstable_createNodeManifest, createNode, touchNode } = actions;
> 34 |   const operations = await buildQueries(pluginOptions);
     |                      ^
  35 |   const client = getClient(pluginOptions);
  36 |   await Promise.all(operations.map(async operation => {
  37 |     const { field, collectionType, singleType, query, syncQuery } = operation;

File: ../node_modules/gatsby-source-strapi/gatsby-node.js:34:22

  TypeError: Cannot read property 'match' of null

  - helpers.js:92 getEntityResponse
    [frontend]/[gatsby-source-strapi]/helpers.js:92:8

  - build-query.js:159 
    [frontend]/[gatsby-source-strapi]/build-query.js:159:24

  - Array.reduce

  - build-query.js:158 getQueryFields
    [frontend]/[gatsby-source-strapi]/build-query.js:158:23

  - build-query.js:187 module.exports
    [frontend]/[gatsby-source-strapi]/build-query.js:187:18

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

  - gatsby-node.js:34 Object.exports.sourceNodes
    [frontend]/[gatsby-source-strapi]/gatsby-node.js:34:22

  - api-runner-node.js:462 runAPI
    [frontend]/[gatsby]/src/utils/api-runner-node.js:462:16

Steps to reproduce:

Versions used:

Root cause

field.type.name is null for renderNavigationChild and renderNavigation in build-query.js:159:24

image
timbrandin commented 2 years ago

Yeah it seems that the strapi-plugin-navigation types doesn't have a name, your fix should do the trick unless you need those types. Please create a PR and I will publish it.