Skip to content

Graphql query failing in any version above 3.4.1 #9454

@monkeymosher

Description

@monkeymosher

Bug report

Describe the bug

My GraphQL query has started failing since version 3.4.2 (up to 3.5.0 so far) while I didn't changed any of the code.

Steps to reproduce the behavior

  1. Submit following graphql query:
query Records(
    $limit: Int!
    $start: Int!
    $sort: String!
    $searchText: String!
  ) {
    records(
      start: $start
      limit: $limit
      sort: $sort
      where: { bands: { name_contains: $searchText } }
    ) {
      id
      title
      colours
      is_colour
      is_handnumbered
      is_testpress
      pressing
      cover {
        formats
      }
      bands(
        limit: 2
      ) {
        id
        name
      }
    }
  }
  1. Receive following error instead of json object with records:
{
  "errors": [
    {
      "message": "select distinct `records`.*, `records`.`name` as `_strapi_tmp_records_name` from `records` left join `heroku_ee6cd360ffb11b3`.`bands_records__records_bands` as `bands_records__records_bands_1` on `bands_records__records_bands_1`.`record_id` = `records`.`id` left join `heroku_ee6cd360ffb11b3`.`bands` as `bands_1` on `bands_records__records_bands_1`.`band_id` = `bands_1`.`id` where LOWER(`bands_1`.`name`) LIKE LOWER('%%') order by `_strapi_tmp_records_name` asc limit 12 - ER_BAD_FIELD_ERROR: Unknown column 'records.name' in 'field list'",
      "locations": [{ "line": 2, "column": 3 }],
      "path": ["records"],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "ER_BAD_FIELD_ERROR",
          "errno": 1054,
          "sqlMessage": "Unknown column 'records.name' in 'field list'",
          "sqlState": "42S22",
          "index": 0,
          "sql": "select distinct `records`.*, `records`.`name` as `_strapi_tmp_records_name` from `records` left join `heroku_ee6cd360ffb11b3`.`bands_records__records_bands` as `bands_records__records_bands_1` on `bands_records__records_bands_1`.`record_id` = `records`.`id` left join `heroku_ee6cd360ffb11b3`.`bands` as `bands_1` on `bands_records__records_bands_1`.`band_id` = `bands_1`.`id` where LOWER(`bands_1`.`name`) LIKE LOWER('%%') order by `_strapi_tmp_records_name` asc limit 12",
          "stacktrace": [
            "Error: ER_BAD_FIELD_ERROR: Unknown column 'records.name' in 'field list'",
            "    at Query.Sequence._packetToError (xxx/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)",
            "    at Query.ErrorPacket (xxx/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)",
            "    at Protocol._parsePacket (xxx/node_modules/mysql/lib/protocol/Protocol.js:291:23)",
            "    at Parser._parsePacket (xxx/node_modules/mysql/lib/protocol/Parser.js:433:10)",
            "    at Parser.write (xxx/node_modules/mysql/lib/protocol/Parser.js:43:10)",
            "    at Protocol.write (xxx/node_modules/mysql/lib/protocol/Protocol.js:38:16)",
            "    at Socket.<anonymous> (xxx/node_modules/mysql/lib/Connection.js:88:28)",
            "    at Socket.<anonymous> (xxx/node_modules/mysql/lib/Connection.js:526:10)",
            "    at Socket.emit (events.js:315:20)",
            "    at Socket.EventEmitter.emit (domain.js:485:12)",
            "    at addChunk (_stream_readable.js:297:12)",
            "    at readableAddChunk (_stream_readable.js:273:9)",
            "    at Socket.Readable.push (_stream_readable.js:214:10)",
            "    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)",
            "    at Protocol._enqueue (xxx/node_modules/mysql/lib/protocol/Protocol.js:144:48)",
            "    at Connection.query (xxx/node_modules/mysql/lib/Connection.js:198:25)",
            "    at xxx/node_modules/knex/lib/dialects/mysql/index.js:130:18",
            "From previous event:",
            "    at Client_MySQL._query (xxx/node_modules/knex/lib/dialects/mysql/index.js:124:12)",
            "    at Client_MySQL.query (xxx/node_modules/knex/lib/client.js:158:17)",
            "    at Runner.query (xxx/node_modules/knex/lib/runner.js:135:36)",
            "    at xxx/node_modules/knex/lib/runner.js:39:23",
            "From previous event:",
            "    at Runner.run (xxx/node_modules/knex/lib/runner.js:25:16)",
            "    at Builder.Target.then (xxx/node_modules/knex/lib/interface.js:14:43)",
            "    at processImmediate (internal/timers.js:456:21)",
            "    at process.topLevelDomainCallback (domain.js:137:15)"
          ]
        }
      }
    }
  ],
  "data": { "records": null }
}

Expected behavior

This request usually provides a json object with a list of records to display in the front-end interface. The expected response looks like this:

{
  "data": {
    "records": [
      {
        "id": "1",
        "title": "In Humor And Sadness",
        "colours": "Pink Marble",
        "is_colour": true,
        "is_handnumbered": false,
        "is_testpress": null,
        "pressing": "2nd press out of 250",
        "cover": {
          "formats": {
            "thumbnail": {
              "hash": "thumbnail_R_6750814_1425855006_7228_jpeg_87492c0c63",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 156,
              "height": 156,
              "size": 8.12,
              "path": null,
              "url": "xxx/thumbnail_R_6750814_1425855006_7228_jpeg_87492c0c63.jpeg"
            },
            "small": {
              "hash": "small_R_6750814_1425855006_7228_jpeg_87492c0c63",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 500,
              "height": 500,
              "size": 62.21,
              "path": null,
              "url": "xxx/small_R_6750814_1425855006_7228_jpeg_87492c0c63.jpeg"
            }
          },
          "__typename": "UploadFile"
        },
        "bands": [{ "id": "2", "name": "'68", "__typename": "Bands" }],
        "__typename": "Records"
      },
      {
        "id": "2",
        "title": "100 Demons",
        "colours": "Solid purple",
        "is_colour": true,
        "is_handnumbered": false,
        "is_testpress": null,
        "pressing": "2nd press out of 336 ",
        "cover": {
          "formats": {
            "thumbnail": {
              "hash": "thumbnail_R_6417068_1456782315_3322_jpeg_59ee383e4d",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 156,
              "height": 156,
              "size": 13.01,
              "path": null,
              "url": "xxx/thumbnail_R_6417068_1456782315_3322_jpeg_59ee383e4d.jpeg"
            },
            "small": {
              "hash": "small_R_6417068_1456782315_3322_jpeg_59ee383e4d",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 500,
              "height": 500,
              "size": 108.42,
              "path": null,
              "url": "xxx/small_R_6417068_1456782315_3322_jpeg_59ee383e4d.jpeg"
            }
          },
          "__typename": "UploadFile"
        },
        "bands": [{ "id": "3", "name": "100 Demons", "__typename": "Bands" }],
        "__typename": "Records"
      },
      {
        "id": "3",
        "title": "Still Searching",
        "colours": "Black",
        "is_colour": false,
        "is_handnumbered": false,
        "is_testpress": null,
        "pressing": "Out of 360",
        "cover": {
          "formats": {
            "thumbnail": {
              "hash": "thumbnail_R_3220164_1321033399_jpeg_4b9d0ec51c",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 156,
              "height": 156,
              "size": 6.45,
              "path": null,
              "url": "xxx/thumbnail_R_3220164_1321033399_jpeg_4b9d0ec51c.jpeg"
            },
            "small": {
              "hash": "small_R_3220164_1321033399_jpeg_4b9d0ec51c",
              "ext": ".jpeg",
              "mime": "image/jpeg",
              "width": 499,
              "height": 500,
              "size": 66.19,
              "path": null,
              "url": "xxx/small_R_3220164_1321033399_jpeg_4b9d0ec51c.jpeg"
            }
          },
          "__typename": "UploadFile"
        },
        "bands": [
          { "id": "6", "name": "A Strength Within", "__typename": "Bands" }
        ],
        "__typename": "Records"
      }
    ]
  }
}

System

  • Node.js version: v13.12.0
  • NPM version: 6.13.4
  • Strapi version: 3.5.0
  • Database: MySQL
  • Operating system: Mac OS Mojave (same problem on Heroku)

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: plugin:graphqlSource is plugin/graphql packagestatus: pending reproductionWaiting for free time to reproduce the issue, or more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions