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

[4.5.13]: the relatedToEntries type is not right in graphQL. #14075

Closed
dande-sun opened this issue Dec 26, 2023 · 6 comments
Closed

[4.5.13]: the relatedToEntries type is not right in graphQL. #14075

dande-sun opened this issue Dec 26, 2023 · 6 comments

Comments

@dande-sun
Copy link

dande-sun commented Dec 26, 2023

What happened?

Description

The relatedToEntries type is not right in graphQL,
I want query all pages of the related to the product page, so I useing the relatedToEntries,
In Craft Documentation the relatedToEntries is a EntryCriteriaInput type, but it returns an error when querying.

The query:

query MyQuery {
  entries(relatedToEntries: {section: "products", slug: "data"}) {
    id
  }
}

The error:

{
  "errors": [
    {
      "debugMessage": "QueryArgument must be either a string, an integer, or a boolean value.",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Validator/Rules/ValuesOfCorrectType.php",
          "line": 220,
          "call": "craft\\gql\\types\\QueryArgument::parseLiteral(instance of GraphQL\\Language\\AST\\ObjectValueNode)"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Validator/Rules/ValuesOfCorrectType.php",
          "line": 89,
          "call": "GraphQL\\Validator\\Rules\\ValuesOfCorrectType::isValidScalar(instance of GraphQL\\Validator\\ValidationContext, instance of GraphQL\\Language\\AST\\ObjectValueNode, 'entries')"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Language/Visitor.php",
          "line": 414,
          "call": "GraphQL\\Validator\\Rules\\ValuesOfCorrectType::GraphQL\\Validator\\Rules\\{closure}(instance of GraphQL\\Language\\AST\\ObjectValueNode, 'value', instance of GraphQL\\Language\\AST\\ArgumentNode, array(8), array(7))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Language/Visitor.php",
          "line": 470,
          "call": "GraphQL\\Language\\Visitor::GraphQL\\Language\\{closure}(instance of GraphQL\\Language\\AST\\ObjectValueNode, 'value', instance of GraphQL\\Language\\AST\\ArgumentNode, array(8), array(7))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Language/Visitor.php",
          "line": 277,
          "call": "GraphQL\\Language\\Visitor::GraphQL\\Language\\{closure}(instance of GraphQL\\Language\\AST\\ObjectValueNode, 'value', instance of GraphQL\\Language\\AST\\ArgumentNode, array(8), array(7))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
          "line": 224,
          "call": "GraphQL\\Language\\Visitor::visit(instance of GraphQL\\Language\\AST\\DocumentNode, array(2))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
          "line": 116,
          "call": "GraphQL\\Validator\\DocumentValidator::visitUsingRules(instance of GraphQL\\Type\\Schema, instance of GraphQL\\Utils\\TypeInfo, instance of GraphQL\\Language\\AST\\DocumentNode, array(26))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 153,
          "call": "GraphQL\\Validator\\DocumentValidator::validate(instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, array(26))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, 'query MyQuery {\n  entries(relatedToEntries: {section: \"products\", slug: \"data\"}) {\n    id\n  }\n}\n', null, array(2), array(3), 'MyQuery', null, array(26))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/craftcms/cms/src/services/Gql.php",
          "line": 514,
          "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, 'query MyQuery {\n  entries(relatedToEntries: {section: \"products\", slug: \"data\"}) {\n    id\n  }\n}\n', null, array(2), array(3), 'MyQuery', null, array(26))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 195,
          "call": "craft\\services\\Gql::executeQuery(instance of craft\\models\\GqlSchema, 'query MyQuery {\n  entries(relatedToEntries: {section: \"products\", slug: \"data\"}) {\n    id\n  }\n}\n', array(3), 'MyQuery', true)"
        },
        {
          "call": "craft\\controllers\\GraphqlController::actionApi()"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array(array(2), array(0))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "call": "yii\\base\\InlineAction::runWithParams(array(2))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "call": "yii\\base\\Controller::runAction('api', array(2))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/craftcms/cms/src/web/Application.php",
          "line": 305,
          "call": "yii\\base\\Module::runAction('graphql/api', array(2))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/craftcms/cms/src/web/Application.php",
          "line": 606,
          "call": "craft\\web\\Application::runAction('graphql/api', array(2))"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/craftcms/cms/src/web/Application.php",
          "line": 284,
          "call": "craft\\web\\Application::_processActionRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/app/avepoint-craft-cms/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "call": "craft\\web\\Application::handleRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/app/avepoint-craft-cms/web-admin/index.php",
          "line": 14,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ]
}

Steps to reproduce

WeCom Screenshot_20231226162843

Expected behavior

WeCom Screenshot_20231226162938

Actual behavior

Craft CMS version

4.5.13

PHP version

8.1.26

Operating system and version

Linux 5.4.0-1105-azure

Database type and version

PostgreSQL 15.4

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.1-13)

Installed plugins and versions

WeCom Screenshot_20231226163238

@dande-sun
Copy link
Author

WeCom Screenshot_20231226164612

@brandonkelly
Copy link
Member

I can’t reproduce that locally. If I execute your exact query, it executes (albeit with no results):

Screenshot 2023-12-26 at 11-26-39 Explore the GraphQL API - Happy Lager

Swapping the section and slug params with valid values (for my install) executes and yields results:

Screenshot 2023-12-26 at 11-26-49 Explore the GraphQL API - Happy Lager

If you send a database backup and your Composer files over to [email protected], we can look into why it’s not working for your install.

@dande-sun
Copy link
Author

@brandonkelly I have send to [email protected],

@brandonkelly
Copy link
Member

This ended up being due to a conflict with a custom field with the handle relatedToEntries.

As of the next release, all of the relatedTo* GraphQL argument names will be in the reserved field handle list, to help avoid these conflicts going forward.

@dande-sun
Copy link
Author

Thanks a lot, I'm going to change the handle name now.

@brandonkelly
Copy link
Member

Craft 4.5.14 is out with that change. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants