{"record":{"id":"413e1a8bc44874d6","repo":"hasura/graphql-engine","slug":"no-such-type-defined-in-the-document-0","errorCode":null,"errorMessage":"no such type defined in the document: {0}","messagePattern":"no such type defined in the document: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/validation/error.rs","lineNumber":39,"sourceCode":"    #[error(\"fragment of type {fragment_type} cannot be spread on type {selection_type}\")]\n    FragmentCannotBeSpread {\n        selection_type: ast::TypeName,\n        fragment_type: ast::TypeName,\n    },\n    // TODO, this error isn't thrown yet\n    #[error(\n        \"a selection set is specified on field '{field_name}' of non-composite type: {type_name}\"\n    )]\n    SelectionOnNonCompositeType {\n        field_name: ast::Name,\n        type_name: ast::TypeName,\n    },\n    #[error(\"no such field on type {type_name}: {field_name}\")]\n    NoFieldOnType {\n        type_name: ast::TypeName,\n        field_name: ast::Name,\n    },\n    #[error(\"no such type defined in the document: {0}\")]\n    UnknownType(ast::TypeName),\n    #[error(\"an internal error occurred during validation: type lookup failed for {type_name}\")]\n    InternalTypeNotFound { type_name: ast::TypeName },\n    #[error(\n        \"an internal error occurred during validation: field {field_name} lookup failed for sub type '{sub_type_name}' of type '{type_name}'\"\n    )]\n    InternalNoFieldOnSubtype {\n        type_name: ast::TypeName,\n        sub_type_name: ast::TypeName,\n        field_name: ast::Name,\n    },\n    #[error(\n        \"different fields {field1} and {field2} cannot be merged under the same alias: {alias}\"\n    )]\n    FieldsConflictDifferentFields {\n        alias: ast::Alias,\n        field1: ast::Name,\n        field2: ast::Name,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/validation/error.rs#L21-L57","documentation":"Thrown when a document references a type name that is not defined in the schema, e.g. a fragment type condition `on DeletedType` or a directive/variable/argument type referencing a missing type. Produced by get_type_info in validation/collect.rs:110 when type lookup fails during validation. It signals schema/document mismatch rather than a malformed selection per se.","triggerScenarios":"Fragment `on` conditions naming types absent from the schema; queries generated against a different (older/newer) schema; renamed or removed types after schema evolution; typos in type condition names.","commonSituations":"Deploying a client built against a newer schema than the server; removing/renaming schema types server-side while stale persisted queries still reference them; multi-environment schema drift.","solutions":["Verify the type name spelling in fragment type conditions and directives against the schema","Regenerate the client/query from the schema version the server actually serves","If you own the schema, keep a deprecation window instead of hard-removing types used by clients"],"exampleFix":"// before\nfragment F on Usr { id }\n// after\nfragment F on User { id }","handlingStrategy":"validation","validationCode":"for name in referenced_type_names(doc) { assert!(schema.has_type(&name), \"unknown type {name}\"); }","typeGuard":"fn type_exists(schema: &Schema, name: &str) -> bool { schema.lookup_type(name).is_some() }","tryCatchPattern":"match validate(doc) { Err(Error::UnknownType(t)) => fail_fast_with_schema_diff(t), r => r }","preventionTips":["Generate clients from the exact schema the server serves","CI-validate persisted queries after every schema change","Prefer additive schema evolution over type removal/renames"],"tags":["graphql","unknown-type","schema-mismatch","validation"],"backgroundTag":"graphql-unknown-type","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}