gatsby-source-google-sheets icon indicating copy to clipboard operation
gatsby-source-google-sheets copied to clipboard

Mixed field types

Open ettzzi opened this issue 5 years ago • 2 comments

Hello, I am trying to receive data from a list of shops. The column "name" contains the names of all shops. I have a name that is called 128 and I think is breaking the plugin:

I receive the following error:

warn There are conflicting field types in your data.

If you have explicitly defined a type for those fields, you can safely ignore this warning message.
Otherwise, Gatsby will omit those fields from the GraphQL schema.

If you know all field types in advance, the best strategy is to explicitly define them with the `createTypes` action, and skip inference with the `@dontInfer` directive.
See https://www.gatsbyjs.org/docs/actions/#createTypes
googleSheetEsercentiRow.name:
 - type: number
   value: 128
 - type: string
   value: 'Clothing Company'

ettzzi avatar Mar 29 '20 12:03 ettzzi

Looks like following the advice in the warning message I have solved the issue by defining a custom type.

      type googleSheetEsercentiRow implements Node {
        address: String
        children: NodeFilterListInput
        id: String
        name: String
        phone1: String,
        phone2: String
        internal: InternalFilterInput
        neighborhood: String
        parent: NodeFilterInput
        type: String          
      }

Is this the best solution?

ettzzi avatar Mar 29 '20 13:03 ettzzi

Worked for me. In my gatsby-node.js:

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions
  const typeDefs = `
    type googleSheetWebsiteDataSourceRow implements Node @dontInfer {
      zip: String!
      businessname: String!
    }
  `
  createTypes(typeDefs)
}

brybeecher avatar Jul 10 '20 01:07 brybeecher