graphql-constraint-directive
Version:
Validate GraphQL fields
50 lines (40 loc) • 1.36 kB
Plain Text
directive @constraint(minLength: Int, maxLength: Int, startsWith: String, endsWith: String, contains: String, notContains: String, pattern: String, format: String, min: Float, max: Float, exclusiveMin: Float, exclusiveMax: Float, multipleOf: Float, minItems: Int, maxItems: Int, uniqueTypeName: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION | ARGUMENT_DEFINITION
type Query {
"""Query books field documented"""
books(
"*Constraints:*\n* Minimal value: `1`\n* Maximal value: `3`\n"
size: Int
" Query argument documented \n\n*Constraints:*\n* Minimal length: `1`\n"
first: String
): [Book]
""" Query book field documented """
book: Book
}
type Book {
"*Constraints:*\n* Maximal length: `10`\n"
title: String
"Book description already documented\n\n*Constraints:*\n* Minimal length: `10`\n* Maximal length: `50`\n"
description: String
authors(
"Book authors argument documented\n\n*Constraints:*\n* Maximal value: `4`\n"
size: Int
"""
Already documented
*Constraints:*
* Minimal length as documented: 1
"""
first: String
): [String]
}
type Mutation {
createBook(input: BookInput): Book
}
input BookInput {
"*Constraints:*\n* Minimal value: `3`\n"
title: Int!
author: AuthorInput
}
input AuthorInput {
"*Constraints:*\n* Minimal length: `2`\n"
name: String!
}