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

Argument id: Got invalid value NaN on prisma.findMany. Provided Float, expected String. #9

Open
sherifawad opened this issue Jul 16, 2022 · 2 comments

Comments

@sherifawad
Copy link

I have an attendances tables and trying to query table with the library.

return await prismaOffsetPagination({
	cursor: cursor,
	size: Number(size),
	buttonNum: Number(buttonNum),
	orderBy,
	orderDirection,
	model: Attendance,
	prisma: prisma,
	where: {
		Profile: { id: studentId },
	},
}); 

The query:

  query Attendances($studentId: String!, $cursor: String, $orderBy: String, $orderDirection: String, $size: Int, $buttonNum: Int) {
      PaginatedAttendances(studentId: $studentId, cursor: $cursor, orderBy: $orderBy, orderDirection: $orderDirection, size: $size, buttonNum: $buttonNum) {
      pageEdges {
          cursor
          node {
              note
              id
              startAt
              endAt
          }
      }
      pageCursors {
          first {
              cursor
              page
              isCurrent
          }
          previous {
              cursor
              page
              isCurrent
          }
          around {
              cursor
              page
              isCurrent
          }
          next {
              cursor
              page
              isCurrent
          }
          last {
              cursor
              page
              isCurrent
          }
      }
          totalCount
      }
  }

the variables are :

"orderBy": "startAt",
"orderDirection": "asc",
"size": 1,
"buttonNum": 5,
"cursor":  null,

The result query:

{
  "data": {
    "PaginatedAttendances": {
      "pageEdges": [
        {
          "cursor": "c2FsdHlzYWx0YmZlOWVjYTItNjY2Ni00ZjI1LTg2NmEtZmQ0MmRhYTAzMTUx",
          "node": {
            "note": "seeded",
            "id": "bfe9eca2-6666-4f25-866a-fd42daa03151",
            "startAt": "2022-06-07T10:39:37.236Z",
            "endAt": "2022-06-07T12:39:37.236Z"
          }
        }
      ],
      "pageCursors": {
        "first": null,
        "previous": null,
        "around": [
          {
            "cursor": "c2FsdHlzYWx0YmZlOWVjYTItNjY2Ni00ZjI1LTg2NmEtZmQ0MmRhYTAzMTUx",
            "page": 1,
            "isCurrent": true
          },
          {
            "cursor": "c2FsdHlzYWx0YjczY2FlODctY2FmNS00ZWRjLWEyNGEtYmUzOTAzMGFkYmI4",
            "page": 2,
            "isCurrent": false
          },
          {
            "cursor": "c2FsdHlzYWx0NTM0MjUwY2YtOGEzNy00NTM5LWE1MjktYmE3Yjk2MDA2ODZj",
            "page": 3,
            "isCurrent": false
          },
          {
            "cursor": "c2FsdHlzYWx0MDBjOTFmNzgtYjlmZi00Yzg3LTg0NGEtYThmNGVmNDYzMDMy",
            "page": 4,
            "isCurrent": false
          }
        ],
        "next": {
          "cursor": "c2FsdHlzYWx0YjczY2FlODctY2FmNS00ZWRjLWEyNGEtYmUzOTAzMGFkYmI4",
          "page": 2,
          "isCurrent": false
        },
        "last": {
          "cursor": "c2FsdHlzYWx0MDZkODg3YWEtNWJlZS00OTg4LTg2N2QtYjEzNTU3OWRhYzhl",
          "page": 6,
          "isCurrent": false
        }
      },
      "totalCount": 6
    }
  }
}

If I use the page 3 cursor in variables:

"orderBy": "startAt",
"orderDirection": "asc",
"size": 1,
"buttonNum": 5,
"cursor":  "c2FsdHlzYWx0NTM0MjUwY2YtOGEzNy00NTM5LWE1MjktYmE3Yjk2MDA2ODZj",

I get an error:

{
  "errors": [
    {
      "message": "\nInvalid `prismaModel.findMany()` invocation in\n/home/eng/repos/academy_management/api/node_modules/prisma-offset-pagination/src/paginator/pageEdge.ts:84:46\n\n   81 // findManyArgsForCursorCount -> cursorCount -> currentPage\n   82 let findManyArgsForCursorCount: Record<string, any>;\n   83 if (findManyArgs?.orderBy) {\n→  84   const cursorObject = await prismaModel.findMany({\n          orderBy: {\n            startAt: 'asc'\n          },\n          where: {\n            Profile: {\n              id: '5a5c3da5-0b65-4b2a-8fcd-49465f35cbbf'\n            }\n          },\n          cursor: {\n            id: NaN\n                ~~~\n          },\n          take: 1\n        })\n\nArgument id: Got invalid value NaN on prisma.findManyAttendance. Provided Float, expected String.\n\n",
      "locations": [
        {
          "line": 2,
          "column": 9
        }
      ],
      "path": [
        "PaginatedAttendances"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "clientVersion": "3.15.2",
          "stacktrace": [
            "Error: ",
            "Invalid `prismaModel.findMany()` invocation in",
            "/home/eng/repos/academy_management/api/node_modules/prisma-offset-pagination/src/paginator/pageEdge.ts:84:46",
            "",
            "   81 // findManyArgsForCursorCount -> cursorCount -> currentPage",
            "   82 let findManyArgsForCursorCount: Record<string, any>;",
            "   83 if (findManyArgs?.orderBy) {",
            "→  84   const cursorObject = await prismaModel.findMany({",
            "          orderBy: {",
            "            startAt: 'asc'",
            "          },",
            "          where: {",
            "            Profile: {",
            "              id: '5a5c3da5-0b65-4b2a-8fcd-49465f35cbbf'",
            "            }",
            "          },",
            "          cursor: {",
            "            id: NaN",
            "                ~~~",
            "          },",
            "          take: 1",
            "        })",
            "",
            "Argument id: Got invalid value NaN on prisma.findManyAttendance. Provided Float, expected String.",
            "",
            "",
            "    at Document.validate (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:47823:20)",
            "    at PrismaClient._executeRequest (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49972:17)",
            "    at consumer (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49916:23)",
            "    at /home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49920:76",
            "    at runInChildSpan (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49133:12)",
            "    at /home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49920:20",
            "    at AsyncResource.runInAsyncScope (node:async_hooks:202:9)",
            "    at PrismaClient._request (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:49919:86)",
            "    at /home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:46474:25",
            "    at _callback (/home/eng/repos/academy_management/api/node_modules/@prisma/client/runtime/index.js:46233:52)"
          ]
        }
      }
    }
  ],
  "data": {
    "PaginatedAttendances": null
  }
}

But some other cursor values work as expected!!

@P1K3N
Copy link

P1K3N commented Jul 18, 2022

exactly the same problem ..
Also, every time I pass a cursor (i needed to pass the id, otherwise it couldn't work) it is also throwing error :

Argument id: Got invalid value NaN on prisma.findManyClient. Provided Float, expected String.

Will this be fixed in short notice?

Otherwise,I don't see the advantage of use this package.
Also the documentation should be improved

@guicuton
Copy link

guicuton commented Oct 20, 2023

This errors looks like to be a wrong conditional position here:

https://github.com/prisma-korea/prisma-offset-pagination/blob/32a26e059661f5902cb07af10092cd31b08b2328/src/paginator/pageEdge.ts#L79C11-L79C11

@sherifawad | @P1K3N - check if the PR helps

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

No branches or pull requests

3 participants