butlerx / gatsby-source-google-spreadsheets

A source plugin for Gatsby that allows reading data from Google Sheets.
MIT License
39 stars 10 forks source link

Plugin does not generate any nodes when there are empty cells in a column #9

Closed krismorf closed 3 years ago

krismorf commented 3 years ago

Describe the bug Plugin fails and does not generate any nodes when there are empty and non-empty cells in a column. (This was introduced in the latest release, v3.0.5 works fine)

To Reproduce Steps to reproduce the behavior:

  1. Create a table like below with at least 1 empty cell
    | First | Second | Third |
    |-------|--------|-------|
    | value | value  | value |
    | value | value  |       |

Output warn The gatsby-source-google-spreadsheets plugin has generated no Gatsby nodes. Do you need it?

butlerx commented 3 years ago

using this sheet I've been unable to replicate the issue https://docs.google.com/spreadsheets/d/1OmF61v8O6QX4nS4DQHO-ul-1CBsZ_KPfQFuxgrkWh90/edit?usp=sharing

querying in graphql with

query ExperienceQuery {

  allGoogleEmptySheet {
    nodes {
      first
      third
      second
    }
  }
}

returns


{
  "data": {
    "allGoogleEmptySheet": {
      "nodes": [
        {
          "first": "value",
          "third": "value",
          "second": "value"
        },
        {
          "first": "value",
          "third": null,
          "second": "value"
        }
      ]
    }
  },
  "extensions": {}
}```
krismorf commented 3 years ago

Thanks for your reply @butlerx .

This is the affected spreadsheet that breaks on 3.0.7: [...]

And this is the error I'm getting:

 ERROR #11321  PLUGIN

"gatsby-source-google-spreadsheets" threw an error while running the sourceNodes lifecycle:

Cannot read property 'replace' of undefined

  TypeError: Cannot read property 'replace' of undefined

  - cleanRows.js:22 convertCell
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet/cleanRows.js:22:31

  - cleanRows.js:14 
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet/cleanRows.js:14:20

  - Array.map

  - cleanRows.js:11 
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet/cleanRows.js:11:10

  - Array.map

  - cleanRows.js:9 Object.exports.cleanRows
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet/cleanRows.js:9:17

  - fetchSheet.js:20 
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet.js:20:44

  - Generator.next

  - fetchSheet.js:5 fulfilled
    [website]/[gatsby-source-google-spreadsheets]/lib/fetchSheet.js:5:58

  - runMicrotasks

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

warn The gatsby-source-google-spreadsheets plugin has generated no Gatsby nodes. Do you need it?
butlerx commented 3 years ago

Ok so the issue only occurs when a column type is a number, it wasn't occurring previously because of a bug some types not being assigned correctly.

butlerx commented 3 years ago

This is now fixed in version v3.0.9