dgraph-io/dgraph · error

argument ` ` in ` ` of List kind has non-object elements…

Error message

argument `%s` in %s `%s` of List kind has non-object elements, Lists can have only objects as element.

What it means

Inside a valid list-of-INPUT_OBJECT argument, each supplied element must itself be an object literal. matchArgSignature recurses into each element via matchArgSignature to validate its fields; if any element value is a scalar, variable, or list rather than an ast.ObjectValue, this error is thrown. It enforces that every list element conforms to the remote input object shape.

Solutions

  1. Make every element of the list an object literal matching the remote INPUT_OBJECT fields (e.g. `[{id: "1"}, {id: "2"}]`).
  2. If scalar elements are correct, the remote list element type is a scalar — fix the remote SDL or use the scalar list form (see related non-object-elements-in-remote error).
  3. If a variable is needed per element, declare it as the input object type: `$item: ItemInput!` inside the list is generally unsupported here — inline the object instead.
  4. Validate query literals with a GraphQL parser/linter before running remote composition.

Example fix

// before
query { createUsers(users: ["alice", {name: "bob"}]) }
// after
query { createUsers(users: [{name: "alice"}, {name: "bob"}]) }
Defensive patterns

Strategy: validation

Validate before calling

// Verify every list element is an object literal
for i, el := range listValue.Children {
    if el.Value.Kind != "ObjectValue" {
        return fmt.Errorf("element %d of arg %s is not an object", i, argName)
    }
}

Type guard

func allElementsAreObjects(v *ast.Value) bool {
    for _, c := range v.Children {
        if c.Value.Kind != ast.ObjectValue { return false }
    }
    return true
}

Try / catch

if err := validateRemoteGraphql(...); err != nil {
    if strings.Contains(err.Error(), "non-object elements, Lists can have only objects") {
        return fmt.Errorf("malformed list literal: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: validateRemoteGraphql -> matchArgSignature recursion on `f(items: ["a", {b: 1}])` — the first element is a scalar, so the per-element ObjectValue check fails before recursion; also hit with nested lists `[ [..] ]`.

Common situations: Mixed element types in a list literal; a variable used as a list element where objects were expected; code-generated queries that inject scalars into an object list; hand-edited queries with a dropped object brace.

Related errors


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

Appendix: source

Thrown at graphql/schema/remote.go:492

				Kind == list && remoteArgTyp.OfType.OfType != nil)) {
				return errors.Errorf("LIST value supplied for argument `%s` in %s `%s`, "+
					"but remote argument doesn't accept LIST.", givenArgName, *md.operationType,
					*md.givenQryName)
			}
			remoteListElemTypname := remoteArgTyp.NamedType()
			remoteObjTyp, ok := md.remoteTypes[remoteListElemTypname]
			if !ok {
				return missingRemoteTypeError(remoteListElemTypname)
			}
			if remoteObjTyp.Kind != inputObject {
				return errors.Errorf("argument `%s` in %s `%s` of List kind has non-object"+
					" elements in remote %s, Lists can have only INPUT_OBJECT as element.",
					givenArgName, *md.operationType, *md.givenQryName, *md.operationType)
			}
			remoteObjChildMap := getRemoteTypeFieldsMetadata(remoteObjTyp)
			for _, givenElem := range givenArgVal.Children {
				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,

View on GitHub (pinned to 759e242be6)