You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is quite common for the nullability of an object in GraphQL to match that of the corresponding object in the Prisma schema.
However, with the current approach, I need to manually specify nullable: true/false in many places, and unfortunately, I sometimes make errors. It would be beneficial if the Prisma plugin could automatically handle this by default.”
In example, if we have a prisma model like this.
model User {
id String @id
name String
tel String?
}
And if we expose those fields. the result should be like this
builder.prismaObject('User',{fields: (t)=>({id: t.exposeID('id'),// should be non-nullablename: t.exposeString('name'),// should be non-nullabletel: t.exposeString('tel'),// should be nullablenullableName: t.exposeString('name',{nullable: true}),// nullable because we override the default}),})
The text was updated successfully, but these errors were encountered:
We might be able to add that as a setting., but this is intentional.
Pothos v4 made changes so that you will now see type-errors if you try to make a nullable field in your db non-nullable in the GraphQL.
Pothos is designed to never rely on the shape of your data to determine the shape of the GraphQL schema. This means that a change in your DB (or other data) should never automatically change the GraphQL schema. This abstraction is critical for making it manageable to maintain large APIs and has worked out really well in the projects I've worked on. It does require adding some extra definitions for which fields are nullable, but to me this is a worthwhile tradeoff.
But, if it seems worth it to you, we could add a setting to the builder that enables mirroring the Schemas nullability
The setting to enable mirroring the schema’s nullability would be perfectly helpful for me. I’m eager to see this feature come to fruition, and I’m available to assist if needed!
It is quite common for the nullability of an object in GraphQL to match that of the corresponding object in the Prisma schema.
However, with the current approach, I need to manually specify
nullable: true/false
in many places, and unfortunately, I sometimes make errors. It would be beneficial if the Prisma plugin could automatically handle this by default.”In example, if we have a prisma model like this.
And if we expose those fields. the result should be like this
The text was updated successfully, but these errors were encountered: