{"record":{"id":"d7ab83ef695a5ead","repo":"dgraph-io/dgraph","slug":"provided-value-is-not-a-scalar-can-t-convert-it-t","errorCode":null,"errorMessage":"provided value is not a scalar, can't convert it to string","messagePattern":"provided value is not a scalar, can't convert it to string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/resolve/query.go","lineNumber":24,"sourceCode":"package resolve\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"strconv\"\n\n\t\"github.com/golang/glog\"\n\t\"go.opentelemetry.io/otel/trace\"\n\n\tdgoapi \"github.com/dgraph-io/dgo/v250/protos/api\"\n\t\"github.com/dgraph-io/dgraph/v25/dql\"\n\t\"github.com/dgraph-io/dgraph/v25/graphql/dgraph\"\n\t\"github.com/dgraph-io/dgraph/v25/graphql/schema\"\n\t\"github.com/dgraph-io/dgraph/v25/x\"\n)\n\nvar errNotScalar = errors.New(\"provided value is not a scalar, can't convert it to string\")\n\n// A QueryResolver can resolve a single query.\ntype QueryResolver interface {\n\tResolve(ctx context.Context, query schema.Query) *Resolved\n}\n\n// A QueryRewriter can build a Dgraph dql.GraphQuery from a GraphQL query,\n// along with any DQL variable bindings (e.g. for parameterized password\n// queries) that must be supplied to the executor.\ntype QueryRewriter interface {\n\tRewrite(ctx context.Context, q schema.Query) ([]*dql.GraphQuery, map[string]string, error)\n}\n\n// QueryResolverFunc is an adapter that allows to build a QueryResolver from\n// a function.  Based on the http.HandlerFunc pattern.\ntype QueryResolverFunc func(ctx context.Context, query schema.Query) *Resolved\n\n// Resolve calls qr(ctx, query)","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/resolve/query.go#L6-L42","documentation":"errNotScalar is returned by convertScalarToString in Dgraph's GraphQL query resolution when a value that must be converted to a string (typically for an @search/@id argument or DQL variable) is not a scalar type. The resolver only knows how to stringify scalar values; objects, lists, or enums passed where a scalar string is expected trigger this. It is a schema/type mismatch rather than a runtime data failure.","triggerScenarios":"Calling a query/mutation whose argument or field resolution path invokes convertScalarToString with a non-scalar value — e.g. an object-typed or list-typed input supplied where a scalar XID or search filter value is expected.","commonSituations":"Mis-typed GraphQL variables in client queries; passing an object where a String was declared; custom scalars that resolve to non-scalar Go values; schema edits that changed a field type without updating client queries.","solutions":["Inspect the GraphQL query/variables being sent and ensure the value passed is a scalar (String/Int/Float/Boolean)","Validate client-side variables against the schema before sending","Fix the schema so the relevant field/argument is declared as a scalar type"],"exampleFix":"// before\nquery($id: [String!]!) { getUser(userId: $id) {...} } // list passed where scalar needed\n// after\nquery($id: String!) { getUser(userId: $id) {...} }","handlingStrategy":"type-guard","validationCode":"if typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' {\n  throw new Error('argument must be a scalar')\n}","typeGuard":"func isScalarValue(v interface{}) bool {\n  switch v.(type) {\n  case string, int, int64, float64, bool, nil:\n    return true\n  }\n  return false\n}","tryCatchPattern":"resp, err := resolver.Resolve(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"provided value is not a scalar\") {\n  // inspect variables sent with the request\n  log.Printf(\"non-scalar value in query vars: %v\", req.Variables)\n}","preventionTips":["Validate client variables against the GraphQL schema","Keep @id and search fields scalar-typed","Avoid custom scalars that resolve to objects"],"tags":["graphql","scalar","type-mismatch","dgraph"],"backgroundTag":"non-scalar-value","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}