Skip to content

Approach to mutation payloads and prisma fields #669

Answered by hayes
giraugh asked this question in Q&A
Discussion options

You must be logged in to vote

Nothing obvious here. This is a hard problem in GraphQL. Generally mutations happen in the root resolvers, and the rest of the query tree ends up being resolved asynchronously after.

Being able to query into something that has just been deleted is probably a pattern that will cause a lot of pain. I would recommend not returning the deleted items in your mutation.

That being said, a potential option would be to create your UserPayload as a "variant" of the User type, and have the user field implemented using the t.variant method. (see https://pothos-graphql.dev/docs/plugins/prisma#type-variants).

You mutation can then be a prismaField that returns the payload variant, and will receive a query

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by giraugh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants