Hi. I have a Prisma model with a JSON field (backed by jsonb
type for postgres). As far as the React<–>GraphQL<–>Prisma<–>DB dataflow goes, it’s all working fine. The problem is the typescript support is not great.
- I have custom type definitions for this column that I use in my app, let’s call that MyType
- On the React/client side of things, this comes up as
Record<string, unknown>
so I cast it to MyType with anas
statement wherever I use it - On the api side of things, Prisma returns a
Prisma.JsonValue
for it, and graphQL still thinks it’s aRecord<string, unknown>
and they are not really compatible with each other without casting both as anobject
(since I don’t have my custom typedefs available on the api side).
My questions are:
- Is there a good way to tell all the involved systems to treat this as MyType
- Failing that, is there a way to have my custom typedefs available on both the web and api sides?
Thanks