dgraph-io/dgraph · error
error querying graphql schema
Error message
error querying graphql schema
What it means
upgradeCORS queries the GraphQL schema via querySchema_v21_03_0 to rewrite it with merged CORS headers. Failure is wrapped as 'error querying graphql schema'. The tool could not fetch the stored GraphQL schema (dgraph.graphql.schema) from the cluster.
Solutions
- Confirm a GraphQL schema exists (query dgraph.graphql.schema via DQL).
- Re-authenticate and re-run the upgrade if the token expired.
- Fix connectivity/HTTP issues to Alpha and retry.
- Inspect Alpha logs for the underlying query failure.
Defensive patterns
Strategy: try-catch
Validate before calling
curl -s http://localhost:8080/query -XPOST -d '{ schema(func: has(dgraph.graphql.schema)) { uid dgraph.graphql.schema } }' Try / catch
if err := getQueryResult(dg, querySchema_v21_03_0, &schemaData); err != nil {
// fetch the stored schema manually if this fails, then retry
return errors.Wrap(err, "error querying graphql schema")
} Prevention
- Ensure a GraphQL schema is deployed before upgrading
- Keep the JWT fresh for the duration of the migration
- Snapshot/backup the schema before running migrations
When it happens
Trigger: getQueryResult fails on the schema query — Alpha unreachable, GraphQL schema predicate absent, or response not parseable into map[string][]sch.
Common situations: Clusters with no GraphQL schema ever deployed; expired auth token; HTTP/network failures; malformed stored schema data from earlier partial migrations.
Related errors
- error querying persisted queries
- Dgraph.Authorization should be only be specified once in a…
- encountered an XID with that isn'tallowed as Xid
- error deleting old acl predicates
- error querying cors
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/f0eb15a229795550.
Report an issue: GitHub.
Appendix: source
Thrown at upgrade/change_v21.03.0.go:234
uid, err := strconv.ParseUint(cors.UID, 0, 64)
if err != nil {
return err
}
if uid > maxUid {
maxUid = uid
if len(cors.Cors) == 1 && cors.Cors[0] == "*" {
// No need to update the GraphQL schema if all origins are allowed.
corsList = corsList[:0]
continue
}
corsList = cors.Cors
}
}
// Get GraphQL schema.
schemaData := make(map[string][]sch)
if err := getQueryResult(dg, querySchema_v21_03_0, &schemaData); err != nil {
return errors.Wrap(err, "error querying graphql schema")
}
var gqlSchema string
maxUid = 0
for _, schema := range schemaData["schema"] {
uid, err := strconv.ParseUint(schema.UID, 0, 64)
if err != nil {
return err
}
if uid > maxUid {
maxUid = uid
gqlSchema = schema.GQLSchema
}
}
// Update the GraphQL schema.
if err := updateGQLSchema(jwt, gqlSchema, corsList); err != nil {
return errView on GitHub (pinned to 759e242be6)