dgraph-io/dgraph · error
can't convert input.what to string
Error message
can't convert input.what to string
What it means
getAssignInput reads input.what from the assign mutation input and requires it to be a string (the kind of value to assign, e.g. "uids"). A missing or non-string 'what' key produces this inputArgError.
Source
Thrown at graphql/admin/assign.go:86
"startId": startId,
"endId": endId,
"readOnly": readOnly,
},
}},
nil,
), true
}
func getAssignInput(m schema.Mutation) (*assignInput, error) {
inputArg, ok := m.ArgValue(schema.InputArgName).(map[string]interface{})
if !ok {
return nil, inputArgError(errors.Errorf("can't convert input to map"))
}
inputRef := &assignInput{}
inputRef.What, ok = inputArg["what"].(string)
if !ok {
return nil, inputArgError(errors.Errorf("can't convert input.what to string"))
}
num, err := parseAsUint64(inputArg["num"])
if err != nil {
return nil, inputArgError(schema.GQLWrapf(err, "can't convert input.num to uint64"))
}
inputRef.Num = num
return inputRef, nil
}
View on GitHub (pinned to 759e242be6)
Solutions
- Add or fix input.what as a string, e.g. {"what": "uids", "num": 100}.
- Check the mutation schema (assignDgraphMutation input type) for the exact field name and type.
- Validate the payload JSON before sending.
Example fix
// before
{"what": 3, "num": 100}
// after
{"what": "uids", "num": 100} Defensive patterns
Strategy: type-guard
Validate before calling
function requireAssignWhat(input) {
if (typeof input?.what !== 'string') throw new Error("input.what must be a string, e.g. 'uids'");
} Type guard
function hasStringWhat(v) { return typeof v === 'object' && v !== null && typeof v.what === 'string' && v.what.length > 0; } Try / catch
try { await assign(input); } catch (e) { if (String(e).includes("can't convert input.what to string")) { throw new Error('Missing or non-string input.what in assign mutation'); } throw e; } Prevention
- Always include what: "uids" (or the intended kind) in assign input
- Keep client types in sync with the assignDgraphMutation input type
- Unit-test mutation payload builders
When it happens
Trigger: assignDgraphMutation input object without a 'what' field, or with a non-string value (number, object, enum passed as non-string) at graphql/admin/assign.go:86.
Common situations: Omitting 'what' in hand-written payloads; confusing the enum-like value and sending an integer; older clients using a removed field name (e.g. 'type') instead of 'what'.
Related errors
- can't convert input to map
- can't convert input to map
- can't convert input to map
- not able to find set args in update mutation
- you must specify a 'destination' value
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/56f090ffc006c11d.
Report an issue: GitHub.