dgraph-io/dgraph · error
scalar value supplied for argument `%s` in %s `%s`, only Var
Error message
scalar value supplied for argument `%s` in %s `%s`, only Variable, Object, or List values are allowed.
What it means
matchArgSignature only supports three kinds of supplied argument values: variables (ast.Variable), object values (ast.ObjectValue), and list values (ast.ListValue). Any other value kind — bare scalars like ints, strings, booleans, enums, or null — falls into the default branch and raises this error. The remote validation path is designed for structured/forwardable arguments, not inline scalar literals.
Source
Thrown at graphql/schema/remote.go:509
if givenElem.Value.Kind != ast.ObjectValue {
return errors.Errorf("argument `%s` in %s `%s` of List kind has non-object"+
" elements, Lists can have only objects as element.", givenArgName,
*md.operationType, *md.givenQryName)
}
if err := matchArgSignature(&argMatchingMetadata{
givenArgVals: getObjChildrenValsAsMap(givenElem.Value),
givenVarTypes: md.givenVarTypes,
remoteArgMd: remoteObjChildMap,
remoteTypes: md.remoteTypes,
givenQryName: md.givenQryName,
operationType: md.operationType,
schema: md.schema,
}); err != nil {
return err
}
}
default:
return errors.Errorf("scalar value supplied for argument `%s` in %s `%s`, "+
"only Variable, Object, or List values are allowed.", givenArgName,
*md.operationType, *md.givenQryName)
}
}
// check all non-null args required by remote query/mutation are present in given query/mutation
for _, remoteArgName := range md.remoteArgMd.requiredArgs {
_, ok := md.givenArgVals[remoteArgName]
if !ok {
return errors.Errorf("argument `%s` in %s `%s` is missing, it is required by remote"+
" %s.", remoteArgName, *md.operationType, *md.givenQryName, *md.operationType)
}
}
return nil
}
View on GitHub (pinned to 759e242be6)
Solutions
- Convert the inline literal to a variable: `query($age: Int!) { user(age: $age) }` and supply the value via the variables map.
- If the argument is genuinely a scalar and remote validation must accept it, wrap it as a variable in the composed query (the library's supported path).
- Check whether the value should be an object/list per the remote argument kind — a scalar here may signal the wrong argument shape.
- If using a code generator, configure it to emit variables instead of inlining constants.
Example fix
// before
query { user(age: 30) }
// after
query($age: Int!) { user(age: $age) } Defensive patterns
Strategy: validation
Validate before calling
// Parameterize scalar literals as variables before composition
// instead of: query { user(age: 30) }
// emit: query($age: Int!) { user(age: $age) }
func checkValueKinds(q *ast.OperationDefinition, remoteArgs map[string]*ast.ArgumentDefinition) error {
for _, a := range q.Selections... { // reject value kinds other than Variable/Object/List
}
return nil
} Type guard
func isSupportedArgValue(k ast.ValueKind) bool {
return k == ast.Variable || k == ast.ObjectValue || k == ast.ListValue
} Try / catch
if err := validateRemoteGraphql(...); err != nil {
if strings.Contains(err.Error(), "scalar value supplied for argument") {
return fmt.Errorf("convert literal to variable: %w", err)
}
return err
} Prevention
- Always parameterize arguments with variables in remote-composed queries
- Configure code generators to emit variables, not inline constants
- Lint for inline literal arguments in query templates
When it happens
Trigger: validateRemoteGraphql -> matchArgSignature on a query passing a literal scalar/enum argument to a remote operation, e.g. `query { user(age: 30) }` or `query { user(status: ACTIVE) }`, where the value kind is not Variable/Object/List.
Common situations: Hand-written queries with inline literal arguments; query builders that inline values instead of parameterizing them; enum literals supplied directly; generated queries missing variable substitution.
Related errors
- provided value is not a scalar, can't convert it to string
- remote %s `%s` accepts %d arguments, It must have only one a
- argument `%s` is not present in remote %s `%s`.
- object value supplied for argument `%s` in %s `%s`, but remo
- LIST value supplied for argument `%s` in %s `%s`, but remote
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/873f0194088fa8e7.
Report an issue: GitHub.