wp-graphql / wp-graphql-tax-query

Adds `tax_query` support to postObject connection queries using WP_Query
46 stars 16 forks source link

Error when using `RootQueryToPageConnectionWhereArgsTaxQueryOperator` enum as a variable #31

Open ltroya-as opened 2 years ago

ltroya-as commented 2 years ago

Hi guys,

I found an issue when passing the RootQueryToPageConnectionWhereArgsTaxQueryOperator enum as a variable, it throws the following error:

{
  "errors": [
    {
      "debugMessage": "Type loader is expected to return a callable or valid type \"RootQueryToPageConnectionWhereArgsTaxQueryOperator\", but it returned null",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      }
    }
  ]
}

This is the stack trace when running the query below on WP-GraphQL 1.6.12: https://gist.github.com/ltroya-as/8b0bf88d8bdbee5bd8789121633c5434

And the query to reproduce the issue:

query getArticlesByCategories(
  $operator: RootQueryToPageConnectionWhereArgsTaxQueryOperator = IN
) {
  pages(
    where: {
      taxQuery: {
        taxArray: [
          {
            terms: ["cat1", "cat2"]
            taxonomy: CATEGORY
            operator: $operator
            field: SLUG
          }
        ]
      }
    }
  ) {
    nodes {
      slug
    }
  }
}

That error happens on the following versions: 1.6.12, 1.8.2, and 1.8.6.

However, it works on 1.5.8

Thread on WP-GraphQL Slack: https://wp-graphql.slack.com/archives/C3NM1M291/p1657813663734659