{"record":{"id":"5135eb70393f0ce6","repo":"hasura/graphql-engine","slug":"multiple-definitions-of-graphql-type-0","errorCode":null,"errorMessage":"multiple definitions of graphql type: {0:}","messagePattern":"multiple definitions of graphql type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/schema/build.rs","lineNumber":20,"sourceCode":"\nuse thiserror::Error;\n\nuse crate::ast::common as ast;\nuse crate::ast::schema as sdl;\nuse crate::ast::schema::ConstDirective;\nuse crate::ast::spanning::Positioned;\nuse crate::ast::spanning::Spanning;\nuse crate::parser;\n\n#[derive(Error, Debug, Clone)]\npub enum Error {\n    #[error(\"internal error when parsing introspection schema : {0:}\")]\n    InternalParseError(Positioned<parser::Error>),\n\n    #[error(\"internal error when building schema: {0:}\")]\n    Internal(String),\n\n    #[error(\"multiple definitions of graphql type: {0:}\")]\n    ConflictingGraphQlType(ast::TypeName),\n}\n\npub type Result<T> = core::result::Result<T, Error>;\n\npub fn build_schema<S>(s: &S) -> std::result::Result<Schema<S>, S::SchemaError>\nwhere\n    S: SchemaContext,\n{\n    let introspection_schema = include_str!(\"introspection.graphql\");\n    let introspection_document = parser::Parser::new(introspection_schema)\n        .parse_schema_document()\n        .map_err(Error::InternalParseError)?;\n    let mut types = BTreeMap::new();\n    let mut introspection_root_fields = BTreeMap::new();\n    let mut builder = Builder {\n        registered_types: HashSet::new(),\n        registered_namespaces: HashSet::new(),","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/schema/build.rs#L2-L38","documentation":"Schema-building error: while merging type definitions from the parsed SDL, two definitions resolved to the same type name with conflicting definitions, so a single schema cannot be built. The conflicting ast::TypeName is reported.","triggerScenarios":"Calling build_schema on a schema definition that defines the same type (e.g. type Foo {...} twice, or type Foo and interface/enum Foo) in separate definitions; also when stitching a base schema with introspection schema types that collide.","commonSituations":"Schema stitching or merging multiple .graphql files that both define a type; copy-pasted type blocks; re-importing a module that already declares a type; version bumps adding duplicate definitions to generated SDL.","solutions":["Search the SDL for the reported type name and deduplicate/merge the definitions","If merging files, exclude one of the conflicting definitions at load time","If extending a type, use `extend type Foo` instead of redefining it","Check generated SDL output for duplicated blocks after codegen changes"],"exampleFix":"# before\ntype User { id: ID }\ntype User { name: String }\n# after\ntype User { id: ID, name: String }\n# or: type User { id: ID }  extend type User { name: String }","handlingStrategy":"validation","validationCode":"fn find_duplicate_types(docs: &[Document]) -> Vec<TypeName> {\n    let mut seen = HashSet::new();\n    docs.iter().flat_map(|d| d.definitions()).filter_map(|def| def.as_type_def())\n        .filter(|t| !seen.insert(t.name.clone())).map(|t| t.name.clone()).collect()\n}\nassert!(find_duplicate_types(&docs).is_empty());","typeGuard":null,"tryCatchPattern":"match build_schema(&defs) { Err(Error::ConflictingGraphQlType(name)) => dedupe_or_report(name), _ => {} } — build_schema returns S::SchemaError, so map this variant at the call site.","preventionTips":["Deduplicate type definitions before merging schema files","Use extend type instead of redefining","Run schema linting in CI"],"tags":["graphql","schema","duplicate-definition","schema-building"],"backgroundTag":"graphql-duplicate-type-definition","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}