Apollo BigInt Support


I’m a novice to graphql and the associated libraries around it, so part of the reason I wanted to try redwoodjs was the out of the box support for graphql. It’s been great not having to configure any of that, and for the most part has worked well.

I’m running into a problem now where I have a postgres field that is a BigInt, and its backed by a prisma schema specifying BigInt.

Contrived example, but something like…

model Example {
  hugeNumber      BigInt

The problem is, when I try to fetch this record using graphql, I get an error:
Int cannot represent non-integer value: 443521878

My suspicion is that the postgres backed field BigInt is not matching up with the Int field I’ve specified in the apollo server like

type Example {
   hugeNumber  Int!

There does not seem to be any BigInt support out of the box in apollo, and I’ve looked at libraries like apollo-type-bigint - npm but I am running into issues because they suggest using things like makeExacutableSchema which I feel like is abstracted away somewhere in redwoodJS. I am not sure how to get support for BigInt, I’m a bit lost, and would love some help! Thanks

Hi @mcgingras and welcome to Redwood.

I think you have run into this issue Support Prisma Native Types Postgres BigInt in SDL · Issue #1733 · redwoodjs/redwood · GitHub where BigInt isn’t a supported type.

A workaround at the moment would be to use a Float but disregard and decimal places.

I’ll see if we can up the priority of this and some other data types ahead of the 1.0 release.

1 Like

Thanks @dthyresson! I appreciate the quick response. I’ll definitely check out using floats.