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

TypeError when using sort/filters on allWpTermNode #30586

Closed
adel0559 opened this issue Mar 31, 2021 · 21 comments · Fixed by #32195
Closed

TypeError when using sort/filters on allWpTermNode #30586

adel0559 opened this issue Mar 31, 2021 · 21 comments · Fixed by #32195
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@adel0559
Copy link

When querying a gatsby dev server (as in http://localhost:8000/__graphql when running gatsby develop) the server crashes if you query allWpTermNode with a filter or sort parameter. The error received looks as follows:

type.resolveType is not a function

  TypeError: type.resolveType is not a function
  
  - node-model.js:648 getFields
    [sitename]/[gatsby]/src/schema/node-model.js:648:29
  
  - node-model.js:661 resolveRecursive
    [sitename]/[gatsby]/src/schema/node-model.js:661:21
  
  - node-model.js:390 resolver
    [sitename]/[gatsby]/src/schema/node-model.js:390:38
  
  - nodes.ts:145 saveResolvedNodes
    [sitename]/[gatsby]/src/redux/nodes.ts:145:30
  
  - node-model.js:388 LocalNodeModel._doResolvePrepareNodesQueue
    [sitename]/[gatsby]/src/schema/node-model.js:388:13
  
  - node-model.js:351 
    [sitename]/[gatsby]/src/schema/node-model.js:351:22
  
  - task_queues.js:79 processTicksAndRejections
    internal/process/task_queues.js:79:11

Steps to reproduce

Query something like the following from a gatsby dev server connected to a wordpress site with some taxonomies added.

allWpTermNode(filter: {count: {gte: 1}}) {
    nodes {
      id
    }
  }

Expected result

The query return the expected terms.

Actual result

Server crashes with the error type.resolveType is not a function

Environment

gatsby: gatsby@next => 3.3.0-next.0
gatsby-background-image: latest => 1.5.0
gatsby-cli: latest => 3.1.0
gatsby-image: latest => 3.1.0
gatsby-plugin-breadcrumb: latest => 12.1.0
gatsby-plugin-compression-v2: latest => 0.1.0
gatsby-plugin-manifest: latest => 3.1.0
gatsby-plugin-offline: latest => 4.1.0
gatsby-plugin-postcss: latest => 4.1.0
gatsby-plugin-purgecss: latest => 6.0.0
gatsby-plugin-react-helmet: latest => 4.1.0
gatsby-plugin-s3: latest => 0.3.8
gatsby-plugin-sass: latest => 4.1.0
gatsby-plugin-sharp: latest => 3.1.2
gatsby-plugin-split-css: latest => 2.0.0
gatsby-plugin-typescript: latest => 3.1.0
gatsby-source-filesystem: latest => 3.1.0
gatsby-source-wordpress: latest => 5.1.0
gatsby-source-wordpress-menus: latest => 1.1.4
gatsby-transformer-sharp: latest => 3.1.0

npmGlobalPackages:
gatsby-cli: 3.0.0

Wordpress 5.7
wp-graphql 1.3.3
wp-gatsby 1.0.7

@adel0559 adel0559 added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 31, 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 31, 2021
@adel0559
Copy link
Author

Looking into this further there seems to be a problem using allWpTermNode in general if you have any custom taxonomies registered.

@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 Apr 6, 2021
@jackonawalk
Copy link
Contributor

Do you experience this same issue in Gatsby v2?

@veryspry veryspry added the status: needs more info Needs triaging and reproducible examples or more information to be resolved label Apr 13, 2021
@henrikwirth
Copy link
Contributor

I experience the same problem. It happens on all filters related to allWpTermNodes and also if I use them in some sort of connection like this:

query MyQuery {
  allWpProject(filter: {terms: {nodes: {elemMatch: {termTaxonomyId: {eq: 10}}}}}) {
    nodes {
      title
    }
  }
}

Running latest versions of all plugins.

@AlexMorrisonDev716
Copy link

AlexMorrisonDev716 commented May 4, 2021

Same issue here.

"gatsby": "^3.4.0",
"gatsby-gravityforms-component": "^3.1.0",
"gatsby-plugin-fontawesome-css": "^1.1.0",
"gatsby-plugin-image": "^1.4.0",
"gatsby-plugin-manifest": "^3.4.0",
"gatsby-plugin-netlify": "^3.4.0",
"gatsby-plugin-netlify-cache": "^1.2.0",
"gatsby-plugin-offline": "^4.4.0",
"gatsby-plugin-purgecss": "^6.0.1",
"gatsby-plugin-react-helmet": "^4.4.0",
"gatsby-plugin-react-svg": "^3.0.1",
"gatsby-plugin-remove-fingerprints": "^0.0.2",
"gatsby-plugin-sass": "^4.4.0",
"gatsby-plugin-sharp": "^3.4.0",
"gatsby-source-filesystem": "^3.4.0",
"gatsby-source-gravityforms": "^1.0.17",
"gatsby-source-wordpress": "^5.4.0",
"gatsby-transformer-sharp": "^3.4.0",

P.S. @henrikwirth Thank you so much for all the help your contributions have made on my latest project :)

@AlexMorrisonDev716
Copy link

I was able to resolve this issue by downgrading wp-graphql to 1.3.5 if anyone needs a quick fix.

@henrikwirth
Copy link
Contributor

I was able to resolve this issue by downgrading wp-graphql to 1.3.5 if anyone needs a quick fix.

Interesting. So with v1.5.6 it breaks?

@jasonbahl
Copy link
Contributor

jasonbahl commented May 5, 2021

@AlexMorrisonDev716 I think getting this to work by downgrading to WPGraphQL v1.3.5 must be a coincidence, because this issue was opened before WPGraphQL 1.3.5 was even released 🤔

@AlexMorrisonDev716
Copy link

@jasonbahl At least with my current combination of packages and plugins v1.3.5 is the last version of WPGraphQL that doesn't cause this error on build.

@tiggeymone
Copy link

tiggeymone commented May 7, 2021

Same error upgrading WpGraphQL. My query involves allWpContentNode:

kcFeed: allWpContentNode(
      filter: {
        contentType: { node: { name: { in: ["post", "news", "project"] } } }
      }
      sort: { fields: date, order: DESC }
    ) {
...

The error diseappears after downgrading WpGraphQL to 1.3.5

@AlexMorrisonDev716
Copy link

@tiggeymone Thank you for replicating this!

@TylerBarnes
Copy link
Contributor

I just had a look at this and it appears to be an issue with Gatsby v3. When downgrading to v2 the query doesn't throw any errors and resolves properly.

Minimal repro here https://github.com/TylerBarnes/gatsby-starter-wordpress-blog-1

@vladar do you have any ideas on what could be causing this or how we can debug it?

@TylerBarnes TylerBarnes added v3migration and removed status: needs more info Needs triaging and reproducible examples or more information to be resolved topic: source-wordpress Related to Gatsby's integration with WordPress labels May 10, 2021
@henrikwirth
Copy link
Contributor

@TylerBarnes I also get an error when I try to update a Term of a Taxonomy while running gatsby develop.

It seems after the update is pushed by WordPress, it can't find Terms anymore, maybe because to update tries to apply filters?

Cannot read property 'allWpTermNode' of null

Not sure if it is related, but it might be.

@duffner
Copy link

duffner commented May 24, 2021

@vladar, do you have any thoughts on the issue? I'm stuck, I wish I had a better idea here, unfortunately.

@duffner
Copy link

duffner commented Jun 1, 2021

@TylerBarnes and @vladar, did we have any luck with this one?

@henrikwirth
Copy link
Contributor

Also still blocked by this on two projects. Any leads to this? Anything I can look into myself?

@credli
Copy link

credli commented Jun 29, 2021

In my case, I'm developing a custom WPGraphQL plugin that extends WooCommerce product term, a misconfiguration in my product connection was causing this error to occur.

@vladar
Copy link
Contributor

vladar commented Jul 1, 2021

Can you try it with gatsby@3.6.2 or later? Could be potentially related: #31710

@vladar
Copy link
Contributor

vladar commented Jul 1, 2021

Turns out this is another edge case of the same underlying issue as #31710 Should be addressed in #32195

@henrikwirth
Copy link
Contributor

@vladar I just tested with latest @3.8.1 and still have the same error. Or were you saying it should be resolved when #32195 is merged?

@TylerBarnes
Copy link
Contributor

@henrikwirth it's resolved in #32195 👍 I tested it on the repro above ☝️ and it works.

@henrikwirth
Copy link
Contributor

@TylerBarnes and @vladar thanks, I just tried and it seems to work for me again 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.