0

Is there a way for me to show TRPC how to serialize bigint? I'm turning BigInt into JSON by

BigInt.prototype.toJSON = function() {       
  return this.toString()
}

And now the issue is when TRPC and Zod validate the big int it fails because its a string.

  • At which point are you using `zod`? Do you get `string`s from the API and want to convert them to `BigInt` on the client? – Souperman Nov 08 '22 at 01:45
  • No, the issue im running into is on the server side. I have a `mutation` and it takes an object one of the `nested objects` has a BigInt coming from the client. Im getting an error from the createRouter() input validation. Im using the T3 trpc set up. – Luis Angel Perez Nov 08 '22 at 13:09

1 Answers1

0

I asked about this on the tRPC discord. The answer was data transformers and using superjson

https://trpc.io/docs/v9/data-transformers