-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Description
Description:
When passing an input object inline with a variable, GraphQL does not apply the default values defined in the schema.
Schema Definition:
mutation:
addUser(
input: AddUserInput! = { type: GUEST }
) : AddUserResponse!
input AddUserInput {
type: UserType! = GUEST
}
Unexpected Behavior
❌ Does NOT Work (default value ignored when using inline arguments)
mutation AddUser_0($type: UserType) {
addUser(input: { type: $type }) {
__typename
}
}
Variables:
{}
🔴 Expected: type = GUEST
🔴 Actual: type = nil → Mutation fails
✅ Works as Expected (default value applied)
mutation AddUser_0($input: AddUserInput) {
addUser(input: $input) {
__typename
}
}
Variables:
{
"input": {}
}
🟢 Result: Default value GUEST is applied correctly.
Expected Behavior:
- Default values defined in the schema (type: UserType! = GUEST) should be applied even when using inline input objects.
- The parser should behave consistently, whether the input is provided inline or as a separate variable.
Steps to Reproduce:
- Define an input type with a required/not required (doesn't work for both) field that has a default value.
- Call a mutation using inline input arguments ({ type: $type }) without passing a variable.
- Observe that the default value is not applied, causing the mutation to fail.
- Compare this with passing $input as a separate variable, where the default value is applied correctly.
Actual Behavior:
- Default values are ignored when using inline input objects ({ type: $type }).
- Default values work only when passing the entire input object as a variable ($input).
Additional Note:
It works well with NodeJS Apollo library
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels