nestjs-query icon indicating copy to clipboard operation
nestjs-query copied to clipboard

Invalid cursor on returned cursor

Open FBurner opened this issue 3 years ago • 1 comments

Describe the bug Get error "Invalid cursor" on providing after cursort to pagination

To Reproduce Steps to reproduce the behavior:

  1. Write query
query {
  campaigns(paging: { first: 1 }) {
    pageInfo {
      hasNextPage
      startCursor
      endCursor
    }
    edges {
      cursor
      node {
        id
        campaignName
        jobListId
        campaignType
      }
    }
  }
}

Result

{
  "data": {
    "campaigns": {
      "pageInfo": {
        "hasNextPage": true,
        "startCursor": "eyJ0eXBlIjoia2V5c2V0IiwiZmllbGRzIjpbeyJmaWVsZCI6ImlkIiwidmFsdWUiOiI2MTgwNGY1MWM2NmNmNzQ3YzcxNDE5NGYifV19",
        "endCursor": "eyJ0eXBlIjoia2V5c2V0IiwiZmllbGRzIjpbeyJmaWVsZCI6ImlkIiwidmFsdWUiOiI2MTgwNGY1MWM2NmNmNzQ3YzcxNDE5NGYifV19"
      },
      "edges": [
        {
          "cursor": "eyJ0eXBlIjoia2V5c2V0IiwiZmllbGRzIjpbeyJmaWVsZCI6ImlkIiwidmFsdWUiOiI2MTgwNGY1MWM2NmNmNzQ3YzcxNDE5NGYifV19",
          "node": {
            "id": "61804f51c66cf747c714194f",
            "campaignName": "test",
            "jobListId": null,
            "campaignType": null
          }
        }
      ]
    }
  }
}
  1. User cursor in query for pagination Query:
query {
  campaigns(paging: { after: "eyJ0eXBlIjoia2V5c2V0IiwiZmllbGRzIjpbeyJmaWVsZCI6ImlkIiwidmFsdWUiOiI2MTgwNGY1MWM2NmNmNzQ3YzcxNDE5NGYifV19", first: 1 }) {
    pageInfo {
      hasNextPage
      startCursor
      endCursor
    }
    edges {
      cursor
      node {
        id
        campaignName
        jobListId
        campaignType
      }
    }
  }
}

Result:

{
  "errors": [
    {
      "message": "Invalid cursor",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "campaigns"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "response": {
            "statusCode": 400,
            "message": "Invalid cursor",
            "error": "Bad Request"
          },
          "status": 400,
          "message": "Invalid cursor",
          "stacktrace": [
            "Error: Invalid cursor",
            "    at KeysetPagerStrategy.decodeCursor (/x/node_modules/@nestjs-query/query-graphql/dist/src/types/connection/cursor/pager/strategies/keyset.pager-strategy.js:84:19)",
            "    at KeysetPagerStrategy.fromCursorArgs (/x/node_modules/@nestjs-query/query-graphql/dist/src/types/connection/cursor/pager/strategies/keyset.pager-strategy.js:22:43)",
            "    at CursorPager.getPageMeta (/x/node_modules/@nestjs-query/query-graphql/dist/src/types/connection/cursor/pager/pager.js:47:38)",
            "    at CursorPager.page (/x/node_modules/@nestjs-query/query-graphql/dist/src/types/connection/cursor/pager/pager.js:18:33)",
            "    at Function.createFromPromise (/xnode_modules/@nestjs-query/query-graphql/dist/src/types/connection/cursor/cursor-connection.type.js:42:69)",
            "    at AutoResolver.queryMany (/xnode_modules/@nestjs-query/query-graphql/dist/src/resolvers/read.resolver.js:42:35)",
            "    at /x/node_modules/@nestjs/core/helpers/external-context-creator.js:69:33",
            "    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
          ]
        }
      }
    }
  ],
  "data": null
}

Expected behavior Not to throw an error.

FBurner avatar Nov 01 '21 20:11 FBurner

Seems the code of nestjs query is hidding actual errors :/

TypeError: Cannot read property 'plugin' of undefined

FBurner avatar Nov 01 '21 20:11 FBurner