Indirect relations
Selecting fields from a nested GraphQL field
By default, the nestedSelection
function will return selections based on the type of the current
field. nestedSelection
can also be used to get a selection from a field nested deeper inside other
fields. This is useful if the field returns a type that is not a prismaObject
, but a field nested
inside the returned type is.
Indirect relations (eg. Join tables)
If you want to define a GraphQL field that directly exposes data from a nested relationship (many to
many relations using a custom join table is a common example of this) you can use the
nestedSelection
function passed to select
.
Given a prisma schema like the following:
You can define a media field that can pre-load the correct relations based on the graphql query: