wp-graphql / wp-graphql-tax-query

Adds `tax_query` support to postObject connection queries using WP_Query
47 stars 17 forks source link

Compatability issue with WPGraphql 1.6+ #27

Open tomgreeEn opened 3 years ago

tomgreeEn commented 3 years ago

The plugin causes an error when attempting to run a taxQuery on a contentNode when using wpGraphQL 1.6.4.

Steps to reproroduce:

This query:

query MyQuery { contentNodes(where: {taxQuery: {relation: AND, taxArray: {field: SLUG, operator: AND, taxonomy: CATEGORY, terms: "watches"}}}) { nodes { ... on NodeWithTitle { title } } } }

Succeeds when using WPGraphql 1.5.9 but fails on 1.6.4 with the message:

Type loader is expected to return a callable or valid type \"RootQueryToContentNodeConnectionWhereArgsTaxArray\", but it returned null"

tomgreeEn commented 3 years ago

On further inspection, the issue is not specific to this plugin - closing issue

tomgreeEn commented 3 years ago

Further investigation confirms this is not specific to contentNodes and is reproducible using only wp-graphql & wp-graphql-tax-query with the updated query:

query MyQuery($taxArray: [RootQueryToPostConnectionWhereArgsTaxArray]!) {
  posts(where: {taxQuery: {relation: AND, taxArray: $taxArray}}) {
    nodes {
      ... on NodeWithTitle {
        title
      }
    }
  }
}

With variables:

{
  "taxArray": [{
    "field": "SLUG",
    "operator": "AND",
    "taxonomy": "CATEGORY",
    "terms": "shoes"
  }]
}

Error message:

Type loader is expected to return a callable or valid type "RootQueryToContentNodeConnectionWhereArgsTaxArray", but it returned null"

Zinkutal commented 3 years ago

Broken by https://github.com/wp-graphql/wp-graphql/pull/2000 Btw, woocommerce was fixed two weeks ago https://github.com/wp-graphql/wp-graphql-woocommerce/pull/537 Transfer from non-working lazy-loading types over to eager type loading

If not addressed, I will take a look at it next week

Offtopic: this extension should be a part of a core plugin, in the worst case a discouraging feature - due to performance issues. Not sure why it is still being not

BenMcD0nald commented 3 years ago

I think I'm getting the same problem trying to use variables...

GraphQL\Error\InvariantViolation: Type loader is expected to return a callable or valid type "RootQueryToVideoConnectionWhereArgsTaxArray", but it returned null

Did anyone work out what the issues is here?

pushljupche commented 2 years ago

Hi,

I'm getting the same error as above on a custom post type taxonomy.

Digging through the code I found out that graphql_input_fields hook is not called because there are no 'input' kind of objects registered in src/Registry/TypeRegistry.php::prepare_type. This seems to be related to the lazy loading input fields.

I still haven't worked out a solution but for now I have downgraded the plugin to 1.5.9.

duffner commented 2 years ago

Hi, all, I'm also getting the same errors as above! I've since downgraded to 1.5.9 to resolve my issues, but i'd like to upgrade.

duffner commented 2 years ago

WP-GraphQL team, this is a pretty active issue being reported in the WP-GraphQL slack, and here. Has there been any attention given to this?

Zinkutal commented 2 years ago

Hi, @duffner, I got lazy 🙃, but needed to fix this quickly.

So, I have created a patch for WPGraphQL - https://gist.github.com/Zinkutal/4d7670f504993d7ff3e8f5bd6167334c

Beware of type changes, ex:

Waiting for https://github.com/wp-graphql/wp-graphql/pull/1387 to be merged