Unify argument validation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
What problem does this feature proposal attempt to solve?
The native spec-compliant validation performed by webonyx/graphql-php (!, scalars) and Lighthouse/Laravel (@rules, @validator) run in different phases and return different error shapes.
This has lead to number of issues:
Which possible solutions should be considered?
type Query {
foo(
nonNull: ID!
customScalar: CustomScalar
required: String @rules(apply: ["required"]
email: String @rules(apply: ["email"]
): ID
}
query EverythingWrong {
# Missing nonNull and required
foo(customScalar: "wrong-format", email: "not-an-email")
}
An optimal solution would combine all kinds of validation in a single, unified step and return a consistent format for which inputs failed validation.
{
"errors": [
{
"message": "Validation failed for the field [foo]",
"extensions": {
"validation": {
"nonNull": ["The nonNull field is required."],
"customScalar": ["The customScalar field must be a valid CustomScalar."],
"required": ["The required field is required."],
"email": ["The email field must be a valid email."]
}
}
}
]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how webonyx/graphql-php handles native validation and how Lighthouse/Laravel process @rules and @validator, then compare the related issues #345 and #262. Use the sample schema and query to trace the separate phases. Done should be defined as a consistent validation step and error shape covering all listed input failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100