{"record":{"id":"be45a784e9f270ea","repo":"dgraph-io/dgraph","slug":"not-resolving-s-there-s-no-graphql-schema-in-dgr","errorCode":null,"errorMessage":"Not resolving %s. There's no GraphQL schema in Dgraph. Use the /admin API to add a GraphQL schema","messagePattern":"Not resolving (.+?)\\. There's no GraphQL schema in Dgraph\\. Use the /admin API to add a GraphQL schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/admin/admin.go","lineNumber":929,"sourceCode":"\t\t\tfunc(m schema.Mutation) resolve.MutationResolver {\n\t\t\t\treturn resolve.NewDgraphResolver(resolve.NewUpdateRewriter(), dgEx)\n\t\t\t}).\n\t\tWithMutationResolver(\"updateGroup\",\n\t\t\tfunc(m schema.Mutation) resolve.MutationResolver {\n\t\t\t\treturn resolve.NewDgraphResolver(NewUpdateGroupRewriter(), dgEx)\n\t\t\t}).\n\t\tWithMutationResolver(\"deleteUser\",\n\t\t\tfunc(m schema.Mutation) resolve.MutationResolver {\n\t\t\t\treturn resolve.NewDgraphResolver(resolve.NewDeleteRewriter(), dgEx)\n\t\t\t}).\n\t\tWithMutationResolver(\"deleteGroup\",\n\t\t\tfunc(m schema.Mutation) resolve.MutationResolver {\n\t\t\t\treturn resolve.NewDgraphResolver(resolve.NewDeleteRewriter(), dgEx)\n\t\t\t})\n}\n\nfunc resolverFactoryWithErrorMsg(msg string) resolve.ResolverFactory {\n\terrFunc := func(name string) error { return errors.Errorf(msg, name) }\n\tqErr :=\n\t\tresolve.QueryResolverFunc(func(ctx context.Context, query schema.Query) *resolve.Resolved {\n\t\t\treturn &resolve.Resolved{Err: errFunc(query.ResponseName()), Field: query}\n\t\t})\n\n\tmErr := resolve.MutationResolverFunc(\n\t\tfunc(ctx context.Context, mutation schema.Mutation) (*resolve.Resolved, bool) {\n\t\t\treturn &resolve.Resolved{Err: errFunc(mutation.ResponseName()), Field: mutation}, false\n\t\t})\n\n\treturn resolve.NewResolverFactory(qErr, mErr)\n}\n\nfunc (as *adminServer) getGlobalEpoch(ns uint64) *uint64 {\n\te := as.globalEpoch[ns]\n\tif e == nil {\n\t\te = new(uint64)\n\t\tas.globalEpoch[ns] = e","sourceCodeStart":911,"sourceCodeEnd":947,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/admin/admin.go#L911-L947","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upload a GraphQL schema first: POST the schema to /admin with updateGQLSchema(input: { set: { schema: \"...\" } }).","Verify you are targeting the correct namespace (X-Dgraph-namespace header).","Check logs for lazyLoadSchema failures that left the namespace without a schema."],"exampleFix":"// before: querying an empty namespace\nPOST /admin { queryUser { id } }\n// after: add a schema first\ncurl -X POST localhost:8080/admin -H 'X-Dgraph-Namespace: 0' \\\n  -d '{\"query\":\"mutation { updateGQLSchema(input: { set: { schema: \\\"type User { id: ID! }\\\" } }) { status } }\"}'","handlingStrategy":"validation","validationCode":"// ensure a schema exists before querying\nconst check = await fetch('/admin', {method:'POST', body: JSON.stringify({query:'{ getGQLSchema { schema } }'})}).then(r=>r.json());\nif (!check.data || !check.data.getGQLSchema || !check.data.getGQLSchema.schema) throw new Error('No GraphQL schema for this namespace; upload one first');","typeGuard":null,"tryCatchPattern":"try { await graphqlQuery(q); } catch (e) { if (String(e).includes('no GraphQL schema in Dgraph')) { await uploadSchema(sdl); await graphqlQuery(q); } else throw e; }","preventionTips":["Always upload a schema to a new namespace before querying it","Set X-Dgraph-Namespace correctly in multi-tenant setups","Include schema bootstrap in deployment automation"],"tags":["graphql","admin","missing-schema","namespace"],"backgroundTag":"missing-graphql-schema","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}