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

TypeError: Do not know how to serialize a BigInt #22

Open
capaj opened this issue Sep 11, 2022 · 4 comments
Open

TypeError: Do not know how to serialize a BigInt #22

capaj opened this issue Sep 11, 2022 · 4 comments

Comments

@capaj
Copy link

capaj commented Sep 11, 2022

TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at stringify (/home/capaj/work-repos/official/official-graphql/prisma-admin/node_modules/express/lib/response.js:1150:12)
    at ServerResponse.json (/home/capaj/work-repos/official/official-graphql/prisma-admin/node_modules/express/lib/response.js:271:14)
    at ServerResponse.send (/home/capaj/work-repos/official/official-graphql/prisma-admin/node_modules/express/lib/response.js:162:21)
    at handler (/home/capaj/work-repos/official/official-graphql/prisma-admin/node_modules/@adminjs/express/src/buildRouter.ts:60:15)

I got this in my schema:

  id               BigInt          @id @default(autoincrement())
@monish96
Copy link

I think this is an issue with prisma itself and nothing to do with adminjs. prisma/studio#816

@UdittLamba
Copy link

facing the same issue

@UdittLamba
Copy link

UdittLamba commented Apr 19, 2023

ok, So I fixed it by patching the bigint prototype
BigInt.prototype.toJSON = function () { const int = Number.parseInt(this.toString()) return int ?? this.toString() }

reference

@capaj
Copy link
Author

capaj commented Apr 19, 2023

Yes we have the same hackfix In our own codebase. This should resolve it.

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