Created
June 22, 2017 12:06
-
-
Save frikille/d6e86fdc33fb26a33d1daac0f752d9f5 to your computer and use it in GitHub Desktop.
custom errors in graphql mutation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// query | |
mutation { | |
createUser(user: {username: "John Doe", email: "john.doe@test"}) { | |
user { | |
username | |
} | |
errors { | |
key | |
message | |
} | |
} | |
} | |
// response | |
{ | |
data { | |
createUser { | |
user: null, | |
errors: [{ | |
key: "email", | |
message: "Email address is invalid" | |
}] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Mutation { | |
createUser(user: CreateUserInput!): UserMutationResponse | |
} | |
input CreateUserInput { | |
username | |
} | |
type CreateUserMutationResponse { | |
user: User | |
errors: [ServiceError] | |
} | |
type User { | |
email: String | |
username: String | |
} | |
type ServiceError { | |
key: String | |
message: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment