{"record":{"id":"8ef5fa632e8e848f","repo":"hasura/graphql-engine","slug":"invalid-graphql-name-0-8ef5fa","errorCode":null,"errorMessage":"invalid graphql name: {0}","messagePattern":"invalid graphql name: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/lexer.rs","lineNumber":159,"sourceCode":"    UnexpectedCharacter(char),\n\n    /// The input source was unexpectedly terminated\n    ///\n    /// Emitted when the current token requires a succeeding character, but\n    /// the source has reached EOF. Emitted when scanning e.g. `\"1.\"`.\n    #[error(\"end of file reached when expecting further input\")]\n    UnexpectedEndOfFile,\n\n    /// An invalid string literal was found\n    #[error(\"invalid string literal found: {0:?}\")]\n    InvalidString(string::Error),\n\n    /// An invalid number literal was found\n    #[error(\"invalid number literal found: {0:?}\")]\n    InvalidNumber(number::Error),\n\n    // An invalid graphql name\n    #[error(\"invalid graphql name: {0}\")]\n    InvalidGraphQlName(String),\n}\n\nimpl From<ast::common::InvalidGraphQlName> for Error {\n    fn from(error: ast::common::InvalidGraphQlName) -> Self {\n        Error::InvalidGraphQlName(error.0)\n    }\n}\n\npub type Result = core::result::Result<Spanning<Token>, Positioned<Error>>;\n\n#[inline]\nfn consume_ascii_chars<F>(data: &[u8], mut f: F) -> usize\nwhere\n    F: FnMut(u8) -> bool,\n{\n    data.iter().take_while(|&&c| f(c)).count()\n}","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/lexer.rs#L141-L177","documentation":"Thrown when a name token does not conform to GraphQL's name grammar (/_A-Za-z][_0-9A-Za-z]*/), such as a name starting with a digit or containing '-'. It can also be produced by converting ast::common::InvalidGraphQlName (names generated programmatically, e.g. from field names, that violate the grammar).","triggerScenarios":"Lexing a document where a name starts with a digit or contains invalid characters ('my-field', '2fast'), or building AST nodes/deriving GraphQL names from external identifiers (DB column names with dashes/spaces) that fail name validation.","commonSituations":"Exposing database columns or JSON keys with hyphens/spaces as GraphQL field or type names; codegen from OpenAPI/protobuf that produces non-identifier names.","solutions":["Rename the field to valid GraphQL name syntax (letters, digits, _, no leading digit)","Add a mapping/alias layer converting external names to sanitized GraphQL names","If from codegen, configure the generator to sanitize identifiers"],"exampleFix":"# before\ntype User { user-name: String }\n# after\ntype User { userName: String }","handlingStrategy":"type-guard","validationCode":"fn valid_graphql_name(n: &str) -> bool {\n    let mut cs = n.chars();\n    matches!(cs.next(), Some(c) if c == '_' || c.is_ascii_alphabetic())\n        && cs.all(|c| c == '_' || c.is_ascii_alphanumeric())\n}","typeGuard":"fn valid_graphql_name(n: &str) -> bool {\n    let mut cs = n.chars();\n    matches!(cs.next(), Some(c) if c == '_' || c.is_ascii_alphabetic())\n        && cs.all(|c| c == '_' || c.is_ascii_alphanumeric())\n}","tryCatchPattern":"Catch Error::InvalidGraphQlName(name) during lexing/AST construction and apply a sanitize_name fallback before retrying.","preventionTips":["Sanitize external identifiers (replace '-', ' ', leading digits) before using them as GraphQL names","Add a naming policy in codegen"],"tags":["graphql","lexer","name","codegen","schema-validation"],"backgroundTag":"graphql-invalid-identifier","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}