Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL Error Unknown field ... on type ... #8053

Closed
JanLenoch opened this issue Sep 11, 2018 · 8 comments
Closed

GraphQL Error Unknown field ... on type ... #8053

JanLenoch opened this issue Sep 11, 2018 · 8 comments
Assignees
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@JanLenoch
Copy link

Description

Occasionally, during the process of building a project with gatsby develop an error occurs:

"GraphQL Error Unknown field some field on type some type"

It definitely happens every time the project is first run (after initializing it with npm install). But, it also happens in other moments, in a random fashion.

Steps to reproduce

  1. Clone https://github.com/Kentico/cloud-gatsby.
  2. Run the project.
  3. Watch the progress in the terminal.

Expected result

The update schema step should be processed without errors.

Actual result

success delete html and css files from previous builds — 0.007 s
success open and validate gatsby-config — 0.008 s
success copy gatsby files — 0.049 s
success onPreBootstrap — 0.525 s
⠁ sourceNodes executes
success source and transform nodes — 0.335 s
success building schema — 0.268 s
success createLayouts — 0.055 s
success createPages — 0.058 s
success createPagesStatefully — 0.035 s
success onPreExtractQueries — 0.001 s
success update schema — 0.172 s
GraphQL Error Unknown field `url` on type `KenticoCloudItemBlogpostReference`

  file: C:/Users/janl/source/repos/cloud-gatsby/src/pages/index.js

   1 |
   2 |   query AllDefaultLanguageItemsQuery {
   3 |     allKenticoCloudItemBlogpostReference(filter: { fields: { languageStep1: { eq: "default" }}}) {
   4 |       edges {
   5 |         node {
   6 |           fields {
   7 |             languageStep1
   8 |           }
   9 |           id
> 10 |           url {
     |           ^
  11 |             value
  12 |           }
  13 |           name___teaser_image__name {
  14 |             value
  15 |           }
  16 |         }
  17 |       }
  18 |     }
  19 |     allKenticoCloudItemProjectReference(filter: { fields: { languageStep1: { eq: "default" }}}) {
  20 |       edges {
success extract queries from components — 0.107 s
success run graphql queries — 0.028 s
success write out page data — 0.016 s
success write out redirect data — 0.002 s
success onPostBootstrap — 0.001 s

Environment

System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Binaries:
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 40.15063.674.0
npmPackages:
gatsby: ^1.9.277 => 1.9.277
gatsby-link: ^1.6.46 => 1.6.46
gatsby-plugin-react-helmet: ^2.0.11 => 2.0.11

error The system cannot find the path specified.

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:7778

  • envinfo.js:1 Object.copySync
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:104976

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123499

  • envinfo.js:1
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124274

  • envinfo.js:1 Promise.all.then.e
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124289

  • From previous event:

  • envinfo.js:1 p
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123986

  • envinfo.js:1 Object.run
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:125487

  • create-cli.js:181 Object.handler
    [npm]/[gatsby-cli]/lib/create-cli.js:181:17

  • command.js:235 Object.runCommand
    [npm]/[gatsby-cli]/[yargs]/lib/command.js:235:44

  • yargs.js:1046 Object.parseArgs [as _parseArgs]
    [npm]/[gatsby-cli]/[yargs]/yargs.js:1046:30

  • yargs.js:551 Object.parse
    [npm]/[gatsby-cli]/[yargs]/yargs.js:551:25

  • create-cli.js:242 module.exports
    [npm]/[gatsby-cli]/lib/create-cli.js:242:157

  • index.js:126 Object.
    [npm]/[gatsby-cli]/lib/index.js:126:1

  • bootstrap_node.js:187 startup
    bootstrap_node.js:187:16

  • bootstrap_node.js:608
    bootstrap_node.js:608:3

error UNHANDLED REJECTION

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:7778

  • envinfo.js:1 Object.copySync
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:104976

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123499

  • envinfo.js:1
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124274

  • envinfo.js:1 Promise.all.then.e
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124289

  • From previous event:

  • envinfo.js:1 p
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123986

  • envinfo.js:1 Object.run
    [npm]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:125487

  • create-cli.js:181 Object.handler
    [npm]/[gatsby-cli]/lib/create-cli.js:181:17

  • command.js:235 Object.runCommand
    [npm]/[gatsby-cli]/[yargs]/lib/command.js:235:44

  • yargs.js:1046 Object.parseArgs [as _parseArgs]
    [npm]/[gatsby-cli]/[yargs]/yargs.js:1046:30

  • yargs.js:551 Object.parse
    [npm]/[gatsby-cli]/[yargs]/yargs.js:551:25

  • create-cli.js:242 module.exports
    [npm]/[gatsby-cli]/lib/create-cli.js:242:157

  • index.js:126 Object.
    [npm]/[gatsby-cli]/lib/index.js:126:1

  • bootstrap_node.js:187 startup
    bootstrap_node.js:187:16

  • bootstrap_node.js:608
    bootstrap_node.js:608:3

@kakadiadarpan kakadiadarpan added type: bug An issue or pull request relating to a bug in Gatsby status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. status: inkteam to review labels Sep 12, 2018
@kakadiadarpan
Copy link
Contributor

I'm able to reproduce this and getting it on the first run and every time .cache the directory is cleared.

@kamerondotcom
Copy link

I am also seeing this error. Similar environment but am seeing the behavior regardless of the .cache directory being cleared.

@Simply007
Copy link
Contributor

I am also seeing this error. Similar environment but am seeing the behavior regardless of the .cache directory being cleared.

same here

@youmustfight
Copy link

youmustfight commented Oct 6, 2018

Found a behavior in my case that might hint at the underlying issue (I'm on v2 btw gatsby@next -> gatsby@2.0.0-rc.28)

I'm pulling in multiple AirTable sources (gatsby-source-airtable@2.0.1) and the table that was throwing this error had a single record which had null values. When I filled all the rows values into the other fields, it no longer threw

@pieh
Copy link
Contributor

pieh commented Oct 9, 2018

@JanLenoch this happens because it this moment gatsby doesn't support class instances when constructing schema

url field that is missing is instance of TextField class ( https://github.com/Enngage/kentico-cloud-js/blob/94ce81548f167530c9376e7a852ac733a708e85b/packages/delivery/lib/fields/field-types.ts#L8-L32 ), which gatsby can't handle first time it sees it. But it works on second try because after serializing data to cache and deserializing it again we get plain object with properties which gatsby can handle

I think fastest way forward would be to normalize fields you get from kentico-cloud-delivery client to plain objects in source plugin. I will try to see if it's feasible to add support for those in gatsby.

@JanLenoch
Copy link
Author

Hi @pieh, thanks for looking into it! Having support for classes would be great as this is what our JS SDK produces by default.

@pieh
Copy link
Contributor

pieh commented Oct 10, 2018

@JanLenoch I've hacky checked yesterday and it seems that what we need is really only way to determine when Object is something we would want to handle - just switching our check here https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/data-tree-utils.js#L174 should be enough to make it work, but not sure what's the best check we can use - switching it to more open _.isObject (or any stuff that only checks for typeof x === 'object') could be problematic because we have whole class of Objects that shouldn't be treated as plain objects (like Date, Number, Array, Map, Set, WeakMap, WeakSet, Promise, ArrayBuffer etc)

JanLenoch pushed a commit to kontent-ai/gatsby-packages that referenced this issue Oct 14, 2018
Works around the "Unknown field ... on type ..." [GraphQL error](gatsbyjs/gatsby#8053).

**Note:** Introduces a breaking change. The data of content elements now reside in the `elements` property, not in the root of each `kenticoCloudItem` node.
@JanLenoch
Copy link
Author

Hi @pieh , I found a semi-hacky way of passing plain objects to Gatsby while still being able to utilize our JS SDK at the same time. We're currently doing a peer review of my PR that brings the plain objects. In the mid-term future, it would still be great if Gatsby supported class instances. That way, we could avoid this semi-hacky solution. I'll close this one for now and I'll file a new issue to support class instances. Thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants