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

allWpMenu query runs fine on WP GraphiQL but results in TypeInfo error locally #30280

Closed
cosmicespresso opened this issue Mar 16, 2021 · 5 comments · Fixed by #30358
Closed
Assignees
Labels
topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby

Comments

@cosmicespresso
Copy link

cosmicespresso commented Mar 16, 2021

On http://localhost:8000/___graphql when I add the connectedNode in the query below:

query MenuData {
  allWpMenu {
    nodes {
      menuItems {
        nodes {
          url
          label
          connectedNode {
	      node {
              id
            }
          }
        }
      }
    }
  }
}

I get the following error:

{
  "errors": [
    {
      "message": "Cannot read property 'typeInfo' of undefined",
      "locations": [
        {
          "line": 9,
          "column": 7
        }
      ],
      "path": [
        "allWpMenu",
        "nodes",
        0,
        "menuItems",
        "nodes",
        5,
        "connectedNode",
        "node"
      ],
      "stack": [
        "TypeError: Cannot read property 'typeInfo' of undefined",
        "    at resolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields/transform-object.js:68:15)",
        "    at resolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby/src/schema/resolvers.ts:569:20)",
        "    at wrappedTracingResolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby/src/schema/resolvers.ts:569:20)",
        "    at resolveField (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:464:18)",
        "    at executeFields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:292:18)",
        "    at collectAndExecuteSubfields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:748:10)",
        "    at completeObjectValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:738:10)",
        "    at completeValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:590:12)",
        "    at resolveField (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:472:19)",
        "    at executeFields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:292:18)",
        "    at collectAndExecuteSubfields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:748:10)",
        "    at completeObjectValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:738:10)",
        "    at completeValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:590:12)",
        "    at /Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:620:25",
        "    at Array.map (<anonymous>)",
        "    at safeArrayFrom (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/jsutils/safeArrayFrom.js:36:23)"
      ]
    },
    {
      "message": "Cannot read property 'typeInfo' of undefined",
      "locations": [
        {
          "line": 9,
          "column": 7
        }
      ],
      "path": [
        "allWpMenu",
        "nodes",
        0,
        "menuItems",
        "nodes",
        6,
        "connectedNode",
        "node"
      ],
      "stack": [
        "TypeError: Cannot read property 'typeInfo' of undefined",
        "    at resolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields/transform-object.js:68:15)",
        "    at resolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby/src/schema/resolvers.ts:569:20)",
        "    at wrappedTracingResolver (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/gatsby/src/schema/resolvers.ts:569:20)",
        "    at resolveField (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:464:18)",
        "    at executeFields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:292:18)",
        "    at collectAndExecuteSubfields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:748:10)",
        "    at completeObjectValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:738:10)",
        "    at completeValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:590:12)",
        "    at resolveField (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:472:19)",
        "    at executeFields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:292:18)",
        "    at collectAndExecuteSubfields (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:748:10)",
        "    at completeObjectValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:738:10)",
        "    at completeValue (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:590:12)",
        "    at /Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/execution/execute.js:620:25",
        "    at Array.map (<anonymous>)",
        "    at safeArrayFrom (/Users/kallirroi/Documents/code/personal/foreignobjects/wordsinspace/node_modules/graphql/jsutils/safeArrayFrom.js:36:23)"
      ]
    }
  ],
  "data": {
    "allWpMenu": {
      "nodes": [
        {
          "menuItems": {
            "nodes": [
              {
                "url": "/2020/12/02/glimmer-refracting-rock/",
                "label": "Glimmer: Refracting Rock",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTY0NQ=="
                  }
                }
              },
              {
                "url": "/2020/12/02/purity-and-security-towards-a-cultural-history-of-plexiglass/",
                "label": "Purity and Security: Towards a Cultural History of Plexiglass",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTYzNg=="
                  }
                }
              },
              {
                "url": "/2021/01/31/digital-ethnography/",
                "label": "Digital Ethnography",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTgwMQ=="
                  }
                }
              },
              {
                "url": "/2021/01/31/mapping-the-field/",
                "label": "Mapping the Field",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTc4Ng=="
                  }
                }
              },
              {
                "url": "/2020/12/03/fluttering-codes-a-cultural-history-of-the-spit-flap/",
                "label": "Fluttering Codes: A Cultural History of the Spit Flap",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTY4OQ=="
                  }
                }
              },
              {
                "url": "/2020/11/12/urban-auscultation-abc-radio/",
                "label": "Urban Auscultation: ABC Radio",
                "connectedNode": {
                  "node": null
                }
              },
              {
                "url": "/encrypted-repositories/",
                "label": "Encrypted Repositories",
                "connectedNode": {
                  "node": null
                }
              }
            ]
          }
        }
      ]
    }
  },
  "extensions": {}
}

Notice how it returns the (somewhat) correct results, but the last two nodes have a node: null.

Expected behaviour
Here is how it's supposed to work, via WP GraphiQL:

{
  menus {
    nodes {
      menuItems {
        nodes {
          url
          label
          connectedNode {
            node {
              id
            }
          }
        }
      }
    }
  }
}

output:

{
  "data": {
    "menus": {
      "nodes": [
        {
          "menuItems": {
            "nodes": [
              {
                "url": "https://icd.wordsinspace.net/2020/12/02/glimmer-refracting-rock/",
                "label": "Glimmer: Refracting Rock",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTY0NQ=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/2020/12/02/purity-and-security-towards-a-cultural-history-of-plexiglass/",
                "label": "Purity and Security: Towards a Cultural History of Plexiglass",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTYzNg=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/2021/01/31/digital-ethnography/",
                "label": "Digital Ethnography",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTgwMQ=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/2021/01/31/mapping-the-field/",
                "label": "Mapping the Field",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTc4Ng=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/2020/12/03/fluttering-codes-a-cultural-history-of-the-spit-flap/",
                "label": "Fluttering Codes: A Cultural History of the Spit Flap",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTY4OQ=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/2020/11/12/urban-auscultation-abc-radio/",
                "label": "Urban Auscultation: ABC Radio",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDo0MTUyNg=="
                  }
                }
              },
              {
                "url": "https://icd.wordsinspace.net/encrypted-repositories/",
                "label": "Encrypted Repositories",
                "connectedNode": {
                  "node": {
                    "id": "cG9zdDoxNTkxNg=="
                  }
                }
              }
            ]
          }
        }
      ]
    }
  },
  "extensions": {
    "debug": []
  }
}

gatsby info

  System:
    OS: macOS 11.2.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.18.4 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.5.2 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 89.0.4389.82
    Firefox: 85.0.2
    Safari: 14.0.3
  npmPackages:
    gatsby: ^3.0.4 => 3.0.4
    gatsby-cli: ^3.0.0 => 3.0.0
    gatsby-image: ^3.0.0 => 3.0.0
    gatsby-plugin-breakpoints: ^1.2.2 => 1.3.3
    gatsby-plugin-manifest: ^3.0.0 => 3.0.0
    gatsby-plugin-modal-routing: ^1.2.0 => 1.2.0
    gatsby-plugin-netlify: ^3.0.0 => 3.0.1
    gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0
    gatsby-plugin-netlify-redirect: ^1.0.0 => 1.0.0
    gatsby-plugin-offline: ^4.0.0 => 4.0.0
    gatsby-plugin-react-helmet: ^4.0.0 => 4.0.0
    gatsby-plugin-react-svg: ^3.0.0 => 3.0.0
    gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
    gatsby-plugin-sharp: ^3.0.1 => 3.0.1
    gatsby-recipes: ^0.2.16 => 0.2.38
    gatsby-remark-social-cards: ^0.4.1 => 0.4.1
    gatsby-source-filesystem: ^3.0.0 => 3.0.0
    gatsby-source-wordpress: ^5.0.0 => 5.0.0
    gatsby-transformer-remark: ^3.0.0 => 3.0.0
    gatsby-transformer-sharp: ^3.0.0 => 3.1.0
  npmGlobalPackages:
    gatsby-cli: 3.0.0
@cosmicespresso cosmicespresso added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 16, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 16, 2021
@LekoArts LekoArts added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 17, 2021
@TylerBarnes TylerBarnes self-assigned this Mar 18, 2021
@cosmicespresso
Copy link
Author

@TylerBarnes after our recent discussion on the MediaItem issue I opened on https://github.com/wp-graphql/, I came back to this and noticed that the url result from the same query is different on WP GraphiQL and on local dev. Above I am querying for the nodes of the (only) Menu I have built on WP. I have also made sure it has an assigned location etc (it had been an issue in the past).

Here's what I get for the first MenuItem node:

WP GraphQL: https://icd.wordsinspace.net/2020/12/02/glimmer-refracting-rock/ (correct)
local dev: /2020/12/02/glimmer-refracting-rock/ 🤔

Not sure if this has to do with how URLs are parsed by the plugin, but I wanted to bring it up. Thanks!

@TylerBarnes
Copy link
Contributor

@Kallirroi thanks for asking - the plugin does replace any URL's and make them relative paths for ease of linking between pages/nodes.

@TylerBarnes
Copy link
Contributor

I have a fix coming for this btw!

@TylerBarnes
Copy link
Contributor

I have a canary with a solution here [email protected]+e45fa4b460. Should be finished and merged next week!

@cosmicespresso
Copy link
Author

I have a canary with a solution here [email protected]+e45fa4b460. Should be finished and merged next week!

That's awesome, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants