hasura / hasura/graphql-engine
Batch input validation not working as expected
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
Version Information
Server Version: v2.33.4
CLI Version (for CLI related issue):
Environment
Local Docker
What is the current behaviour?
When inserting batch objects only the first one gets validated:
mutation InsertUsers($users: [users_insert_input!]!) {
insert_users(
objects: $users
) {
affected_rows
returning {
full_name
phone_numbers {
number
}
}
}
}
Here below it fails as expected as the first number is not valid
{
"users": [
{
"imported_id": "1247775",
"first_name": "Pozzi",
"last_name": "",
"emails": {
"data": [
{
"email": "mariefoti@bluewin.ch"
}
]
},
"phone_numbers": {
"data": [
{
"number": "764881022",
"primary": true
},
{
"number": "+41700081022",
"primary": true
}
]
},
"language": "fr",
"home_address_route": "",
"home_address_postcode": "",
"home_address_locality": "",
"home_address_country_code": ""
}
]
}
Here below it passes with not errors and inserts both numbers in the db. The second one bypasses validation
If I insert more than 1 user in only validate 1st number of 1st user
{
"users": [
{
"imported_id": "1247775",
"first_name": "Pozzi",
"last_name": "",
"emails": {
"data": [
{
"email": "mariefoti@bluewin.ch"
}
]
},
"phone_numbers": {
"data": [
{
"number": "+41700081022",
"primary": true
},
{
"number": "764881022",
"primary": true
},
]
},
"language": "fr",
"home_address_route": "",
"home_address_postcode": "",
"home_address_locality": "",
"home_address_country_code": ""
}
]
}
What is the expected behaviour?
It should validate all phone numbers
How to reproduce the issue?
- create an input validation
- try inserting n+1 objects
Screenshots or Screencast
Please provide any traces or logs that could help here.
Any possible solutions/workarounds you're aware of?
Keywords
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 reproducing the insert_users mutation with multiple users and nested phone_numbers, following the two payload examples in the issue. Trace the input-validation path for batch inserts and compare which phone-number entries are checked. Done means every phone number in every inserted object is validated and invalid values are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100