Closed masterkain closed 1 year ago
@masterkain Thanks for the report, i'll take a look into this
It took me a while to look this up, thanks for your patience
1. Importing prisma
I've added more details on the documentation for crud.prismaImporter
option:
How to import the Prisma namespace at the objects.ts file. Default
"import { Prisma } from '.prisma/client';"
. Please use "resolverImports" to import prismaClient at resolvers.
In your case, please use crud.resolverImports
option :)
About prisma in context, I didn't know about this behavior... I'll update the example to contribute to more people using the direct import prisma.
2. Typo on docs You're correct, fixed
3. defineExposeObject error I'll look into this soon
4. Missing PrismaTypes in readme This lib was created to be integrated with the Prisma Pothos Official Plugin, but in fact this information is not obvious... So, added.
5. JSON type error Please, pass <Prisma.Decimal, Prisma.InputJsonValue, Prisma.InputJsonValue> parameters in Scalars type in the builder definition. (like in readme) I will remove the possibility of leaving these parameters invalid. Although not all users will use JSON, I think it's worth it to be safe.
I'll take a look at error 3 as soon as possible. Thank you very much for your contribution.
Hi @masterkain I was unable to reproduce your 3 issue. ↓
Can you please share a minimal reproducible example?
@Cauen for issue 3;
I've seen the same issue, and what I've found is that it seems like the defineExposeObject
is used for known, primitive types like int
and string
. For BigInt
on a normal field it seems to be using the more verbose util function defineFieldObject
which works fine.
I can see this issue occuring when adding the @id
attribute in the prisma schema, when a BigInt
actually is generated to use the defineExposeObject
util function instead of the defineFieldObject
- which raises this error.
I.e. in the prisma schema id BigInt @default(autoincrement())
works fine, but id BigInt @id @default(autoincrement())
fails.
I would assume the expected behaviour is that id BigInt @id @default(autoincrement())
also generates a defineFieldObject
for the field in the generated objects.base.ts
file.
I'd say it's fairly common to use BigInt
for id's - so this for me is a blocker for going to prod. I'll have a look if I can get started helping out a bit on the repo as I find this generation very nice 🥳 Keep up the good work!
On a separate note - is there any value in making this a plugin for Pothos ? I was considering playing around and seeing if that could be neat.
Thanks for explanation @vleandersson Fixed in 0.6.0 \o/
edit: you can view all the code in this
graphql
branch: https://github.com/icoretech/airbroke/tree/graphql/lib/graphqlhello, I'm trying to work my way towards making this work without typescript errors but I've found some hiccups.
1) issue with importing prisma
this is the config I'm playing with, let's see some generated files
as we can see this contains
await _context.prisma.project.count({
because we did not specifyprismaCaller
. however if we do, and set theresolversImports
it will not be imported:now we have
await prisma.project.count({
but no import.not only that but from the docs https://pothos-graphql.dev/docs/plugins/prisma#set-up-the-builder
https://github.com/microsoft/TypeScript/issues/45405
I'm not familiar with any of this but the default
_context.prisma
goes through this process?2)
export * as Inputs
https://github.com/Cauen/prisma-generator-pothos-codegen#create-a-configuration-file-optional
this line
is present in the readme, I'm not sure the
export
is correct.3)
lib/graphql/__generated__/project/object.base.ts
here I have two typescript errors, one on
t.exposeID('id'
and one ondefineExposeObject('Bigint'
:I've seen something mentioned about
BigInt
rename in the readme, here the second warning goes away withBigInt
.this is the schema I'm working with and this is the builder
4) missing
PrismaTypes
in readmealways in the readme we see the code above, but perhaps it should be corrected to include
PrismaTypes: PrismaTypes,
?5) JSONB
on
parent.backtrace
: