{"record":{"id":"259d12941ec45874","repo":"hasura/graphql-engine","slug":"name-is-not-a-valid-graphql-name","errorCode":null,"errorMessage":"'{name:}' is not a valid GraphQL name.","messagePattern":"'(.+?)' is not a valid GraphQL name\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/ir/src/error.rs","lineNumber":52,"sourceCode":"#[derive(Error, Debug, Transitive)]\n#[transitive(from(json::Error, InternalError))]\n#[transitive(from(gql::normalized_ast::Error, InternalError))]\n#[transitive(from(InternalEngineError, InternalError))]\n#[transitive(from(InternalDeveloperError, InternalError))]\npub enum Error {\n    #[error(\"The global ID {encoded_value:} couldn't be decoded due to {decoding_error:}\")]\n    FailureDecodingGlobalId {\n        encoded_value: String,\n        decoding_error: String,\n    },\n\n    #[error(\"Unexpected value: expecting {expected_kind:}, but found: {found:}\")]\n    UnexpectedValue {\n        expected_kind: &'static str,\n        found: json::Value,\n    },\n\n    #[error(\"'{name:}' is not a valid GraphQL name.\")]\n    TypeFieldInvalidGraphQlName { name: String },\n\n    #[error(\"'{alias:} is not a valid alias\")]\n    InvalidAlias { alias: String },\n\n    #[error(\"{value} is not a valid limit value\")]\n    InvalidLimitValue { value: u32 },\n\n    #[error(\"{value} is not a valid offset value\")]\n    InvalidOffsetValue { value: u32 },\n\n    #[error(\"field '{field_name:} not found in entity representation\")]\n    FieldNotFoundInEntityRepresentation { field_name: FieldName },\n\n    #[error(\n        \"order_by expects a list of input objects with exactly one key-value pair per input object. Please split the input object with multiple key-value pairs into a list of single key-value pair objects.\"\n    )]\n    OrderByObjectShouldExactlyHaveOneKeyValuePair,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/ir/src/error.rs#L34-L70","documentation":"The IR layer validates that entity/type/field names used in queries or configuration conform to the GraphQL name grammar (^[_A-Za-z][_0-9A-Za-z]*$). When a name contains invalid characters (spaces, dashes, leading digits, etc.) this error names the offending name. It guards against injection of malformed identifiers deeper into planning and SQL generation.","triggerScenarios":"A query or configuration uses a type or field name with characters outside the GraphQL name grammar — e.g. 'my-field', '2users', 'user name' — reaching the IR name validation path.","commonSituations":"Dynamically building queries from user input; configuration files mapping database column names with dashes directly to GraphQL field names; codegen producing names that weren't sanitized.","solutions":["Rename the field/type to a valid GraphQL identifier (camelCase or snake_case, letter or underscore first)","If mapping from external names, apply a sanitization/aliasing step before constructing the query","Add a regex check for ^[_A-Za-z][_0-9A-Za-z]*$ before using client-supplied names"],"exampleFix":"# before\nquery {{ user {{ my-field }} }}\n\n# after\nquery {{ user {{ myField }} }}","handlingStrategy":"validation","validationCode":"const NAME_RE = /^[_A-Za-z][_0-9A-Za-z]*$/;\nif (!NAME_RE.test(fieldName)) throw new TypeError(`Invalid GraphQL name: ${{fieldName}}`);","typeGuard":"function isValidGraphqlName(name: string): boolean {{\n  return /^[_A-Za-z][_0-9A-Za-z]*$/.test(name);\n}}","tryCatchPattern":null,"preventionTips":["Sanitize dynamically built names against the GraphQL name grammar","Never interpolate raw user input into query text","Prefer parameterized variables over string-built selections"],"tags":["graphql","naming","validation","identifier","rust"],"backgroundTag":"invalid-graphql-name","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}