Overview of Validation in OverblogGraphQLBundle
masterThe bundle provides tight integration with the Symfony Validator Component to validate user input data.
Key requirements and behaviors:
- Schema Format: Currently supports only GraphQL schemas defined with YAML.
- Mechanism: You apply constraints directly in your YAML type definitions within
args(forobjecttypes) orfields(forinput-objecttypes). - Automation: The bundle automatically validates data and throws an exception if validation fails. This exception is caught and returned in the GraphQL response to the client.
- Execution Timing: Validation occurs automatically before the corresponding resolver is called. If validation fails, the resolver is skipped (unless you manually perform validation inside the resolver).
# Example of applying constraints in a Mutation
Mutation:
type: object
config:
fields:
register:
type: User
args:
username:
type: String!
validation:
- Length:
min: 6
max: 32