dgraph-io/dgraph · error

Not resolving %s. There's no GraphQL schema in Dgraph. Use t

Error message

Not resolving %s. There's no GraphQL schema in Dgraph. Use the /admin API to add a GraphQL schema

What it means

resolverFactoryWithErrorMsg builds a resolver factory whose fallback query resolver rejects every query with this formatted message. It is installed when there is no usable GraphQL schema in Dgraph for the namespace, so any incoming query name is substituted into the message and returned as an error result.

Source

Thrown at graphql/admin/admin.go:929

			func(m schema.Mutation) resolve.MutationResolver {
				return resolve.NewDgraphResolver(resolve.NewUpdateRewriter(), dgEx)
			}).
		WithMutationResolver("updateGroup",
			func(m schema.Mutation) resolve.MutationResolver {
				return resolve.NewDgraphResolver(NewUpdateGroupRewriter(), dgEx)
			}).
		WithMutationResolver("deleteUser",
			func(m schema.Mutation) resolve.MutationResolver {
				return resolve.NewDgraphResolver(resolve.NewDeleteRewriter(), dgEx)
			}).
		WithMutationResolver("deleteGroup",
			func(m schema.Mutation) resolve.MutationResolver {
				return resolve.NewDgraphResolver(resolve.NewDeleteRewriter(), dgEx)
			})
}

func resolverFactoryWithErrorMsg(msg string) resolve.ResolverFactory {
	errFunc := func(name string) error { return errors.Errorf(msg, name) }
	qErr :=
		resolve.QueryResolverFunc(func(ctx context.Context, query schema.Query) *resolve.Resolved {
			return &resolve.Resolved{Err: errFunc(query.ResponseName()), Field: query}
		})

	mErr := resolve.MutationResolverFunc(
		func(ctx context.Context, mutation schema.Mutation) (*resolve.Resolved, bool) {
			return &resolve.Resolved{Err: errFunc(mutation.ResponseName()), Field: mutation}, false
		})

	return resolve.NewResolverFactory(qErr, mErr)
}

func (as *adminServer) getGlobalEpoch(ns uint64) *uint64 {
	e := as.globalEpoch[ns]
	if e == nil {
		e = new(uint64)
		as.globalEpoch[ns] = e

View on GitHub (pinned to 759e242be6)

Solutions

  1. Upload a GraphQL schema first: POST the schema to /admin with updateGQLSchema(input: { set: { schema: "..." } }).
  2. Verify you are targeting the correct namespace (X-Dgraph-namespace header).
  3. Check logs for lazyLoadSchema failures that left the namespace without a schema.

Example fix

// before: querying an empty namespace
POST /admin { queryUser { id } }
// after: add a schema first
curl -X POST localhost:8080/admin -H 'X-Dgraph-Namespace: 0' \
  -d '{"query":"mutation { updateGQLSchema(input: { set: { schema: \"type User { id: ID! }\" } }) { status } }"}'
Defensive patterns

Strategy: validation

Validate before calling

// ensure a schema exists before querying
const check = await fetch('/admin', {method:'POST', body: JSON.stringify({query:'{ getGQLSchema { schema } }'})}).then(r=>r.json());
if (!check.data || !check.data.getGQLSchema || !check.data.getGQLSchema.schema) throw new Error('No GraphQL schema for this namespace; upload one first');

Try / catch

try { await graphqlQuery(q); } catch (e) { if (String(e).includes('no GraphQL schema in Dgraph')) { await uploadSchema(sdl); await graphqlQuery(q); } else throw e; }

Prevention

When it happens

Trigger: Calling any GraphQL query on /admin (or a user GraphQL endpoint) when as.gqlSchemas has no current schema for that namespace — i.e. the namespace has never had a schema added via /admin.

Common situations: Fresh namespace with no GraphQL schema uploaded yet; schema was dropped/deleted; querying the wrong namespace (e.g. no guard instead of 0); lazy-load failed at startup.

Related errors


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