Skip to content

Instantly share code, notes, and snippets.

@clarencenpy
Last active June 5, 2018 20:48
Show Gist options
  • Save clarencenpy/27c3c3ad0e735d3b4c033d58ae0c869b to your computer and use it in GitHub Desktop.
Save clarencenpy/27c3c3ad0e735d3b4c033d58ae0c869b to your computer and use it in GitHub Desktop.
const typeDefs = gql`
# define wrapper result type that could return either
# the added Event on success, or an array of Errors
# on error. Notice both fields are nullable.
type AddEventResult {
event: Event
validationErrors: [FieldValidationError!]
}
# define how you want errors to be represented. This
# can be as complex as your app requires
type FieldValidationError {
field: String!
message: String!
(... any other fields you need)
}
input EventInput {
name: String!
date: Date!
capacity: Int!
photoUrl: String!
}
type Mutation {
addEvent(event: EventInput!): AddEventResult!
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment