{"record":{"id":"e8865785b5886ca3","repo":"dgraph-io/dgraph","slug":"expected-only-one-unique-typename-in-representat","errorCode":null,"errorMessage":"expected only one unique typename in `_representations` argument, got: [%s, %s]","messagePattern":"expected only one unique typename in `_representations` argument, got: \\[(.+?), (.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/wrappers.go","lineNumber":1762,"sourceCode":"\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)\n\n\t// iterate over all the representations and parse\n\tfor i, rep := range representations {\n\t\trepresentation, ok = rep.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"error parsing %dth item in the `_representations` argument\", i)\n\t\t}\n\n\t\ttypename, ok = representation[Typename].(string)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"unable to extract __typename from %dth item in the\"+\n\t\t\t\t\" `_representations` argument\", i)\n\t\t}\n\t\tif typename != entityReprs.TypeDefn.Name() {\n\t\t\treturn nil, fmt.Errorf(\"expected only one unique typename in `_representations`\"+\n\t\t\t\t\" argument, got: [%s, %s]\", entityReprs.TypeDefn.Name(), typename)\n\t\t}\n\n\t\tkeyVal, ok := representation[keyFldName]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"unable to extract value for key field `%s` from %dth item in\"+\n\t\t\t\t\" the `_representations` argument\", keyFldName, i)\n\t\t}\n\t\tentityReprs.KeyVals = append(entityReprs.KeyVals, keyVal)\n\t\tentityReprs.KeyValToRepresentation[fmt.Sprint(keyVal)] = representation\n\t}\n\n\treturn entityReprs, nil\n}\n\nfunc (q *query) AuthFor(jwtVars map[string]interface{}) Query {\n\t// copy the template, so that multiple queries can run rewriting for the rule.\n\treturn &query{","sourceCodeStart":1744,"sourceCodeEnd":1780,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/wrappers.go#L1744-L1780","documentation":"Federation requires all representations in one `_entities` call to belong to the same entity type (this implementation enforces a single unique typename). This error fires when the `__typename` of the item at index i differs from the typename established for the batch, reporting both names.","triggerScenarios":"Passing representations of two different entity types (e.g. Product and Review) in a single `_representations` array.","commonSituations":"Bundling entities from multiple resolvers into one _entities call, or a gateway merging representations from different types into one batch.","solutions":["Split the call so each `_entities` request contains representations of only one type","Filter the representations array by __typename before batching","Check upstream code that aggregates representations to avoid cross-type mixing"],"exampleFix":"// before\n[{\"__typename\":\"Product\",\"upc\":\"1\"},{\"__typename\":\"Review\",\"id\":\"2\"}]\n// after\n[{\"__typename\":\"Product\",\"upc\":\"1\"}] // separate call for Review","handlingStrategy":"validation","validationCode":"types := map[string]bool{}\nfor _, rep := range representations {\n  types[rep[\"__typename\"].(string)] = true\n}\nif len(types) > 1 { return errors.New(\"_representations must contain a single typename\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Group representations by __typename and issue one _entities call per type","Never batch heterogeneous entity types together","Enforce single-typename batching in gateway code"],"tags":["graphql","federation","batching"],"backgroundTag":"mixed-entity-types-in-entities-query","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}