Type variants
The prisma plugin supports defining multiple GraphQL types based on the same prisma model.
Additional types are called variants
. You will always need to have a "Primary" variant (defined as
described above). Additional variants can be defined by providing a variant
option instead of a
name
option when creating the type:
You can define variant fields that reference one variant from another:
You can also use variants when defining relations by providing a type
option:
You may run into circular reference issues if you use 2 prisma object refs to reference each other.
To avoid this, you can split out the field definition for one of the relationships using
builder.prismaObjectField
This same workaround applies when defining relations using variants.