Closed emroot closed 5 months ago
Result before:
"getCollection": {
"items": {
"pageInfo": {
"endCursor": "R1BDOlM6ZWUyOGY1NDktNmUxOS00ZDQ5LWE5N2EtYjUzZmFiMzMyZWY4",
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": "R1BDOlM6ZmQ5YzE5YWUtYTg1MS00YjQzLWI3NDItMGU1NjFiMDY1MGI4"
},
"edges": [
{
"cursor": "R1BDOlM6ZmQ5YzE5YWUtYTg1MS00YjQzLWI3NDItMGU1NjFiMDY1MGI4",
"node": {
"properties": [
{
"value": "Test"
},
{
"value": ""
},
{
"value": ""
}
],
"id": "Q29sbGVjdGlvbkl0ZW06ZmQ5YzE5YWUtYTg1MS00YjQzLWI3NDItMGU1NjFiMDY1MGI4"
}
},
Result after:
{
"data": {
"getCollection": {
"items": {
"pageInfo": {
"endCursor": "fd9c19ae-a851-4b43-b742-0e561b0650b8",
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": "3dc81413-9b1f-4039-8380-3cf026bb770c"
},
"edges": [
{
"cursor": "3dc81413-9b1f-4039-8380-3cf026bb770c",
"node": {
"properties": [
{
"value": "Test"
},
{
"value": ""
},
{
"value": ""
}
],
"id": "Q29sbGVjdGlvbkl0ZW06M2RjODE0MTMtOWIxZi00MDM5LTgzODAtM2NmMDI2YmI3NzBj"
}
},
You can use the format/parsePrismaCursor helpers defined here: https://github.com/hayes/pothos/blob/main/packages/plugin-prisma/src/util/cursors.ts#L33-L47
awesome thank you
Hey there,
I'm been using t.relatedConnection, but because of prisma's limitation on order on a JSONB field, I need to build my query by hand.
Before
I rewrote my code in this way:
Still need to figure out how to optimize my query, but I was curious how to return my cursor, startCursor, endCursor in the same format as t.relatedConnection. Also should I be using
resolveCursorConnection
or do you recommend using a different function? Seems like toCursor is required, maybe there's another way to do this by using relatedConnection and keep using cursor: 'id'Thanks