{"record":{"id":"3d813a99ee549340","repo":"dgraph-io/dgraph","slug":"internal-error-3d813a","errorCode":null,"errorMessage":"Internal error","messagePattern":"Internal error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/resolve/resolver.go","lineNumber":457,"sourceCode":"func New(s schema.Schema, resolverFactory ResolverFactory) *RequestResolver {\n\treturn &RequestResolver{\n\t\tschema:    s,\n\t\tresolvers: resolverFactory,\n\t}\n}\n\n// Resolve processes r.GqlReq and returns a GraphQL response.\n// r.GqlReq should be set with a request before Resolve is called\n// and a schema and backend Dgraph should have been added.\n// Resolve records any errors in the response's error field.\nfunc (r *RequestResolver) Resolve(ctx context.Context, gqlReq *schema.Request) (resp *schema.Response) {\n\tspan := trace.SpanFromContext(ctx)\n\tstop := x.SpanTimer(span, methodResolve)\n\tdefer stop()\n\n\tif r == nil {\n\t\tglog.Errorf(\"Call to Resolve with nil RequestResolver\")\n\t\treturn schema.ErrorResponse(errors.New(ErrInternal))\n\t}\n\n\tif r.schema == nil {\n\t\tglog.Errorf(\"Call to Resolve with no schema\")\n\t\treturn schema.ErrorResponse(errors.New(ErrInternal))\n\t}\n\n\tstartTime := time.Now()\n\tresp = &schema.Response{\n\t\tExtensions: &schema.Extensions{\n\t\t\tTracing: &schema.Trace{\n\t\t\t\tVersion:   1,\n\t\t\t\tStartTime: startTime.Format(time.RFC3339Nano),\n\t\t\t},\n\t\t},\n\t}\n\t// Panic Handler for mutation. This ensures that the mutation which causes panic\n\t// gets logged in Alpha logs. This panic handler overrides the default Panic Handler","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/resolve/resolver.go#L439-L475","documentation":"ErrInternal (\"Internal error\") is returned by Resolve when it is called with a nil RequestResolver. This is a defensive programmer-error guard: the resolver object was never constructed or was zeroed before use. Nothing about the user's request caused it — the embedding application passed a nil resolver into the GraphQL execution path.","triggerScenarios":"Embedding Dgraph's GraphQL layer in a Go application and calling resolver.Resolve(ctx, req) where the resolver variable is nil (never initialized via the constructor, or a struct field left unset).","commonSituations":"Custom Go services using dgraph/graphql as a library; wiring errors after refactoring; failing to check an earlier construction error so a nil resolver propagates.","solutions":["Ensure the RequestResolver is constructed and non-nil before calling Resolve","Check the error from resolver construction/initialization before use","Add a startup assertion or unit test that the resolver is wired"],"exampleFix":"// before\nvar r *resolve.RequestResolver\nresp := r.Resolve(ctx, req) // nil\n// after\nr := resolve.NewRequestResolver(...)\nif r == nil { log.Fatal(\"resolver init failed\") }\nresp := r.Resolve(ctx, req)","handlingStrategy":"validation","validationCode":"if resolver == nil {\n  return errors.New(\"GraphQL resolver not initialized\")\n}\nif err := resolver.Ready(); err != nil {\n  return err\n}","typeGuard":"func resolverReady(r *resolve.RequestResolver) bool { return r != nil }","tryCatchPattern":"defer func() {\n  if rec := recover(); rec != nil {\n    log.Printf(\"GraphQL resolve panic: %v\", rec)\n  }\n}()\nresp := resolver.Resolve(ctx, req)","preventionTips":["Initialize the resolver in one well-tested constructor path","Check construction errors before storing the resolver","Add a startup health check that resolves a trivial request"],"tags":["graphql","internal-error","nil-resolver","dgraph"],"backgroundTag":"nil-resolver","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}