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

Adding the same table-field to multiple entry types creates invalid graphQL schema #10173

Closed
jishi opened this issue Nov 28, 2021 · 3 comments
Closed
Assignees
Labels

Comments

@jishi
Copy link

jishi commented Nov 28, 2021

Description

Given this mutation (which adds rows to a table)

mutation {
  save_thesection_thetype_Entry (
    					siteId: 1,
    					title: "test titel",
    					slug: "test-press",
    					mndLinks: [{ col1: "test", col2: "uirl"}]
            ) {
    id
  }
}

Is working fine on the first entrytype and section I used it on. When trying to use the exact same field (mndLinks) on a different section and type, I get the error:

Field \"save_thesection_thetype_Entry\" argument \"mndLinks\" requires type mndLinks_TableRowInput, found [{col1: \"test\", col2: \"uirl\"}].

Not sure why it expects a table to not be an array of mndLinks_TableRowInput in this case, but it is for the working entry type? Figured it might be a bug, but upgraded to the latest version and still the same thing.

But also, if I do change the data to not be an array, it throws an underlying error:

{
  "errors": [
    {
      "debugMessage": "array_key_exists() expects parameter 2 to be array, string given",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "file": "/app/vendor/craftcms/cms/src/fields/Table.php",
      "line": 389,
      "trace": [
        {
          "file": "/app/vendor/craftcms/cms/src/web/ErrorHandler.php",
          "line": 84,
          "call": "yii\\base\\ErrorHandler::handleError(2, 'array_key_exists() expects parameter 2 to be array, string given', '/app/vendor/craftcms/cms/src/fields/Table.php', 389)"
        },
        {
          "call": "craft\\web\\ErrorHandler::handleError(2, 'array_key_exists() expects parameter 2 to be array, string given', '/app/vendor/craftcms/cms/src/fields/Table.php', 389, array(5))"
        },
        {
          "file": "/app/vendor/craftcms/cms/src/fields/Table.php",
          "line": 389,
          "function": "array_key_exists('col1', 'test')"
        },

Which tells me that it is the graphQL schema that is wrong, but I have no idea on how to fix it...?

EDIT: I just noticed, that if I remove this field from the first EntryType, the schema becomes correct. As soon as I re-add it, the same error appears. Must surely be a bug.

Steps to reproduce

  1. Create a table field, add it to one entry type.
  2. Add the same field to a second entrytype (I have in in a different site and section as well), inspect the graphQL schema, it is not define as an array

Additional info

  • Craft version: 3.7.22
  • PHP version: 7.4.23
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions:
    Amazon S3 1.3.0
    PathTools 1.0.7
    Redactor 2.8.8
    Redirect Manager 1.1.1
    Retcon 2.3.0
    Super Table 2.6.8
    Tags 1.0.9
    Webhooks 2.3.3
@andris-sevcenko
Copy link
Contributor

Ah, my bad. Nice catch! Just fixed it for the next release!

@jishi
Copy link
Author

jishi commented Nov 29, 2021

@andris-sevcenko Awesome, thank you for the quick fix! Impressive as always.

@brandonkelly
Copy link
Member

brandonkelly commented Dec 2, 2021

Craft 3.7.24 is out with that fix. Thanks for reporting!

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

No branches or pull requests

3 participants