craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

[5.x]: GraphQL tried to load an unregistered type "EntryCriteriaInput". #15726

Closed stephenheron closed 6 days ago

stephenheron commented 1 week ago

What happened?

Description

We upgraded from Craft 5.3.6 to 5.4.x and our GraphQL queries started breaking.

The error suggests it is something todo with the EntryCriteriaInput, I looked at the documentation to check that if perhaps EntryCriteriaInput had been removed but it is still in the documentation.

We didn't change anything in our code so it feels like something has changed between 5.3.6 and 5.4.x

Our query is quite simple:

query ContentFinderCountQuery(
  $search: String
  $section: [String]
  $relatedToEntries: [EntryCriteriaInput]
  $siteId: [QueryArgument]!
  $orderBy: String
  $endDate: [QueryArgument]
) {
  entryCount(
    search: $search
    section: $section
    relatedToEntries: $relatedToEntries
    siteId: $siteId
    endDate: $endDate
    orderBy: $orderBy
  )
}

Exception below:

{
  "errors": [
    {
      "exception": "craft\\errors\\GqlException",
      "message": "Tried to load an unregistered type \"EntryCriteriaInput\". This can indicate both a typo in the query or an issue with the schema used.",
      "file": "/app/vendor/craftcms/cms/src/gql/TypeLoader.php",
      "line": 39,
      "trace": [
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 350,
          "function": "loadType",
          "class": "craft\\gql\\TypeLoader",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 326,
          "function": "loadType",
          "class": "GraphQL\\Type\\Schema",
          "type": "->"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Utils/AST.php",
          "line": 579,
          "function": "getType",
          "class": "GraphQL\\Type\\Schema",
          "type": "->"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Utils/AST.php",
          "line": 569,
          "function": "typeFromAST",
          "class": "GraphQL\\Utils\\AST",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 436,
          "function": "typeFromAST",
          "class": "GraphQL\\Utils\\AST",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 322,
          "function": "typeFromAST",
          "class": "GraphQL\\Utils\\TypeInfo",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Language/Visitor.php",
          "line": 466,
          "function": "enter",
          "class": "GraphQL\\Utils\\TypeInfo",
          "type": "->"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Language/Visitor.php",
          "line": 277,
          "function": "GraphQL\\Language\\{closure}",
          "class": "GraphQL\\Language\\Visitor",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
          "line": 224,
          "function": "visit",
          "class": "GraphQL\\Language\\Visitor",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
          "line": 116,
          "function": "visitUsingRules",
          "class": "GraphQL\\Validator\\DocumentValidator",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 153,
          "function": "validate",
          "class": "GraphQL\\Validator\\DocumentValidator",
          "type": "::"
        },
        {
          "file": "/app/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 93,
          "function": "promiseToExecute",
          "class": "GraphQL\\GraphQL",
          "type": "::"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/services/Gql.php",
          "line": 526,
          "function": "executeQuery",
          "class": "GraphQL\\GraphQL",
          "type": "::"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 195,
          "function": "executeQuery",
          "class": "craft\\services\\Gql",
          "type": "->"
        },
        {
          "function": "actionApi",
          "class": "craft\\controllers\\GraphqlController",
          "type": "->"
        },
        {
          "file": "/app/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array"
        },
        {
          "file": "/app/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "function": "runWithParams",
          "class": "yii\\base\\InlineAction",
          "type": "->"
        },
        {
          "file": "/app/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "function": "runAction",
          "class": "yii\\base\\Controller",
          "type": "->"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/web/Application.php",
          "line": 350,
          "function": "runAction",
          "class": "yii\\base\\Module",
          "type": "->"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/web/Application.php",
          "line": 649,
          "function": "runAction",
          "class": "craft\\web\\Application",
          "type": "->"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/web/Application.php",
          "line": 312,
          "function": "_processActionRequest",
          "class": "craft\\web\\Application",
          "type": "->"
        },
        {
          "file": "/app/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "function": "handleRequest",
          "class": "craft\\web\\Application",
          "type": "->"
        },
        {
          "file": "/app/web/index.php",
          "line": 12,
          "function": "run",
          "class": "yii\\base\\Application",
          "type": "->"
        }
      ]
    }
  ]
}

Craft CMS version

5.4.0, 5.4.1, 5.4.2

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

i-just commented 6 days ago

Hi, thanks for getting in touch!

The error you’re seeing is related to this feature added in 5.4.0. If you change EntryCriteriaInput to EntryRelationCriteriaInput, it’ll start working again.

We’ll get the docs updated - thanks for pointing that out!

stephenheron commented 6 days ago

Hi,

Thanks for that, all working now!

Thanks, Stephen