{"record":{"id":"8e32adbc7ff25694","repo":"dgraph-io/dgraph","slug":"type-s-not-found-in-the-schema","errorCode":null,"errorMessage":"type %s not found in the schema","messagePattern":"type (.+?) not found in the schema","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/wrappers.go","lineNumber":1729,"sourceCode":"\trepresentations, ok := q.ArgValue(\"representations\").([]interface{})\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error parsing `representations` argument\")\n\t}\n\tif len(representations) == 0 {\n\t\treturn nil, fmt.Errorf(\"expecting at least one item in `representations` argument\")\n\t}\n\trepresentation, ok := representations[0].(map[string]interface{})\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error parsing %dth item in the `_representations` argument\", 0)\n\t}\n\ttypename, ok := representation[Typename].(string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unable to extract __typename from %dth item in the\"+\n\t\t\t\" `_representations` argument\", 0)\n\t}\n\ttyp := q.op.inSchema.schema.Types[typename]\n\tif typ == nil {\n\t\treturn nil, fmt.Errorf(\"type %s not found in the schema\", typename)\n\t}\n\tkeyDir := typ.Directives.ForName(apolloKeyDirective)\n\tif keyDir == nil {\n\t\treturn nil, fmt.Errorf(\"type %s doesn't have a key Directive\", typename)\n\t}\n\tkeyFldName := keyDir.Arguments[0].Value.Raw\n\n\t// initialize the struct to return\n\tentityReprs := &EntityRepresentations{\n\t\tTypeDefn: &astType{\n\t\t\ttyp:             &ast.Type{NamedType: typename},\n\t\t\tinSchema:        q.op.inSchema,\n\t\t\tdgraphPredicate: q.op.inSchema.dgraphPredicate,\n\t\t},\n\t\tKeyVals:                make([]interface{}, 0, len(representations)),\n\t\tKeyValToRepresentation: make(map[string]map[string]interface{}),\n\t}\n\tentityReprs.KeyField = entityReprs.TypeDefn.Field(keyFldName)","sourceCodeStart":1711,"sourceCodeEnd":1747,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/wrappers.go#L1711-L1747","documentation":"Error returned during federated entity resolution in graphql/schema/wrappers.go when the __typename supplied in a representation does not correspond to any type defined in the GraphQL schema. Fix by referencing an existing type name or updating the schema.","triggerScenarios":"_entities query with a representation whose __typename refers to a type absent from the subgraph schema (typo, removed type, or schema deployed before the query source updated).","commonSituations":"Schema drift between gateway and subgraph after a deploy; renaming a type without updating all federation configs; stale supergraph referencing an old subgraph type.","solutions":["Correct the __typename to a type defined in the subgraph schema","Redeploy/synchronize the subgraph schema with the gateway supergraph","Run a schema check to find removed/renamed types referenced by federation"],"exampleFix":"// before\nrepresentations: [{__typename: \"Produkt\", id: \"1\"}]\n// after\nrepresentations: [{__typename: \"Product\", id: \"1\"}]","handlingStrategy":"validation","validationCode":"types := schema.Types() // from the deployed subgraph schema\nif !types[rep[\"__typename\"].(string)] {\n\treturn fmt.Errorf(\"type %v not in subgraph schema\", rep[\"__typename\"])\n}","typeGuard":"func typeInSchema(typename string, schema *ast.Schema) bool {\n\treturn schema != nil && schema.Types[typename] != nil\n}","tryCatchPattern":"entity, err := q.RepresentationsArg()\nif err != nil && strings.Contains(err.Error(), \"not found in the schema\") {\n\treturn nil, fmt.Errorf(\"unknown entity type: %w\", err)\n}","preventionTips":["Run schema checks in CI to catch renamed/removed types referenced by the supergraph","Deploy subgraph and supergraph schemas atomically","Validate __typename values against the current schema in gateway middleware"],"tags":["graphql","federation","schema"],"backgroundTag":"type-not-found-in-schema","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}