prisma-tools
prisma-tools copied to clipboard
Union types in Prisma Select support
Union types are not supported at all :(
{
_entities(representations: [{__typename: General, id: "cjnvxsos80fwh0918ffd7ie52"}]) {
...on General {
id
foundationYear
agriculturalSquare
},
...on AgeStat {
population {
ages {
malesPercent
}
}
}
}
}
Gives:
representations: [
[Object: null prototype] {
__typename: 'General',
id: 'cjnvxsos80fwh0918ffd7ie52'
}
],
select: {
id: true,
foundationYear: true,
agriculturalSquare: true,
population: { select: [Object] }
}
I understand that unions are not part of prisma, but it would be great to have this for custom queries.
Format TBD, but as a variant something like this:
{
select: { __on: { General: { id: true } } }
}
Yeah, this would be pretty good.
In a simple approach, just returning two major objects with their selections would also be sufficient, like:
{
General: { select: { id: true } },
AgeStat: { select: { id: true } }
}
Of course, the above just an example to clarify this idea.
Guys, is there any chance to add this functionality?