Validation of properties in GraphQL

484 Views Asked by At
input MessageInput {
  content: String
  author: String
}

type Message {
  id: ID!
  content: String
  author: String
}

type Query {
  getMessage(id: ID!): Message
}

type Mutation {
  createMessage(input: MessageInput): Message
}

Message content can be max length 255. How to document that max length is 255 characters? How/Where to do this validation?

1

There are 1 best solutions below

0
On

On the server-side, you would validate in the resolver for the createMessage mutation.

I would also recommend having some sort of client-side validation as well!