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

  1. Convert the inline literal to a variable: `query($age: Int!) { user(age: $age) }` and supply the value via the variables map.
  2. 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).
  3. Check whether the value should be an object/list per the remote argument kind — a scalar here may signal the wrong argument shape.
  4. 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

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


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/873f0194088fa8e7. Report an issue: GitHub.