graphile / crystal-pre-merge

Repository moved
https://github.com/graphile/crystal
39 stars 10 forks source link

V5 - PgConnectionArgOrderByPlugin Regression - Error when passing null in orderBy variable #487

Closed mattiarossi closed 7 months ago

mattiarossi commented 10 months ago

Using V5, either in library mode or local server or in cli mode, the PgConnectionArgOrderByPlugin throws an error if passing an orderBy variable set as null: (Using the Demo database from graphile/demo) Query:

query MyQuery($first: Int, $orderBy: [UsersOrderBy!]) {
  users(first: $first, orderBy: $orderBy) {
    nodes {
      username
      authoredArticles {
        nodes {
          title
          url
        }
      }
    }
  }
}

Variables:

{
  "first": 5,
  "orderBy" :null
}

Error:

{
  "data": {
    "users": null
  },
  "errors": [
    {
      "message": "An error occurred (logged with hash: 'gI-xRchWPlyq39FMFlCQIfA2-dQ', id: '33LRV3HNCP')",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "users"
      ],
      "extensions": {
        "errorId": "33LRV3HNCP",
        "stack": [
          "Error: Invalid!",
          "    at /Users/postgraphile-v5-playground/node_modules/graphile-build-pg/dist/plugins/PgConnectionArgOrderByPlugin.js:126:15",
          "    at Object.plan [as applyPlan] (/Users/postgraphile-v5-playground/node_modules/graphile-build-pg/dist/plugins/PgConnectionArgOrderByPlugin.js:109:33)",
          "    at /Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:443:62698",
          "    at OperationPlan.withModifiers (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:225:21713)",
          "    at Object.apply (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:443:62555)",
          "    at d (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:443:59177)",
          "    at t.withFieldArgsForArguments (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:443:65092)",
          "    at t.withGlobalLayerPlan (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:443:16675)",
          "    at OperationPlan.planField (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:225:20211)",
          "    at OperationPlan.processGroupedFieldSet (/Users/postgraphile-v5-playground/node_modules/grafast/dist/index.js:225:14506)"
        ]
      }
    }
  ]
}