1
votes

Following is the schema

type Payload {
    name: String!
    address: String!
    phone: String
}

type Mutation {
    login(username: String!, password: String!): Payload!
}

Following is the resolver for Payload

Payload: {
    user: {
        resolve: async (parent, args, context, info) => {
            // Some logic here
            throw err;
        }
    }
}

When I throw error from child resolver (here payload resolver) graphql still return all payload data return from Parent resolver and for only user field it return error. Can we change this behaviour to return only error which child resolver throws ?

1

1 Answers

0
votes

I don't think that is possible. According to the GraphQL Response Documentation:

  • If any data is resolved and and error is thrown, both will be returned by the server.