make graphql mutation return multiple types

make graphql mutation return multiple types


0

i’m working on creating mutations for a project i’m working on but stuck on the resolver returns, i won’t to handle the errors while i’m at it as well by sending back messages for notifications to make it user friendly, but let’s say my mutation is UPDATE_USER and it should also return the updated user instance, how can i set my mutation to double returns if possible?

that’s how it looks

export const UPDATE_USER = {
    type: UserType,
    args: {
        user_id: {type: GraphQLString}!,
        first_name: {type: GraphQLString}!,
        last_name: {type: GraphQLString},

but i want something like this incase there’s no user like the update failed for some reason

export const UPDATE_USER = {
    type: UserType|| MessageType,
    args: {
        user_id: {type: GraphQLString}!,
        first_name: {type: GraphQLString}!,
        last_name: {type: GraphQLString},

but i can’t find a way to make it work

Share

New contributor

Mohhaliim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 7 more related questions


Show fewer related questions

0

Reset to default



Leave a Reply

Your email address will not be published. Required fields are marked *