{"record":{"id":"c918da9f20b4f38f","repo":"facebook/relay","slug":"expected-directive-to-have-an-export-name-argu","errorCode":null,"errorMessage":"Expected @{} directive to have an export_name argument","messagePattern":"Expected @(.+?) directive to have an export_name argument","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-typegen/src/visit.rs","lineNumber":2315,"sourceCode":"                panic!(\n                    \"Expected @{} directive to have a path argument\",\n                    *CUSTOM_SCALAR_DIRECTIVE_NAME\n                )\n            })\n            .expect_string_literal();\n\n        let import_path = typegen_context.project_config.js_module_import_identifier(\n            &typegen_context\n                .project_config\n                .artifact_path_for_definition(typegen_context.definition_source_location),\n            &PathBuf::from(path.lookup()),\n        );\n\n        let export_name = directive\n            .arguments\n            .named(ArgumentName(*EXPORT_NAME_CUSTOM_SCALAR_ARGUMENT_NAME))\n            .unwrap_or_else(|| {\n                panic!(\n                    \"Expected @{} directive to have an export_name argument\",\n                    *CUSTOM_SCALAR_DIRECTIVE_NAME\n                )\n            })\n            .expect_string_literal();\n        custom_scalars.insert((export_name, PathBuf::from(import_path.lookup())));\n        return AST::RawType(export_name);\n    }\n    // TODO: We could implement custom variables that are provided via the\n    // config by inserting them into the schema with directives, thus avoiding\n    // having two different ways to express typed custom scalars internally.\n    if let Some(custom_scalar) = typegen_context\n        .project_config\n        .typegen_config\n        .custom_scalar_types\n        .get(&scalar_name.item)\n    {\n        match custom_scalar {","sourceCodeStart":2297,"sourceCodeEnd":2333,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-typegen/src/visit.rs#L2297-L2333","documentation":"Companion to the path-argument panic: when the custom scalar directive is present, its export_name argument (the exported JS type's name) is mandatory. If arguments.named(EXPORT_NAME_CUSTOM_SCALAR_ARGUMENT_NAME) returns None, the compiler panics instead of generating broken output.","triggerScenarios":"transform_graphql_scalar_type encounters a custom scalar directive that has a path argument but no export_name argument while generating type information.","commonSituations":"Partially written annotations; refactors that removed export_name; hand-edited generated/introspection data; tooling that only emits one of the two required arguments.","solutions":["Add the export_name argument naming the exported JS type for the scalar.","Verify the argument spelling matches the compiler constant (export_name).","Keep path and export_name always supplied together in the directive.","Update the emitting tool to a version that always writes both arguments."],"exampleFix":"// before\n@customScalar(path: \"./src/types/MyScalarType.ts\")\n// after\n@customScalar(path: \"./src/types/MyScalarType.ts\", export_name: \"MyScalarType\")","handlingStrategy":"validation","validationCode":"if (hasCustomScalarDirective(node) && !getArg(node, 'export_name')) throw new Error('custom scalar directive requires an export_name argument');","typeGuard":"function hasExportNameArg(directive) { return directive.arguments?.some(a => a.name.value === 'export_name'); }","tryCatchPattern":null,"preventionTips":["Treat path + export_name as an atomic pair in the directive","Review hand-edited or generated annotations in code review","Keep the annotation-emitting tool updated to emit both arguments"],"tags":["typegen","custom-scalar","directive","panic"],"backgroundTag":"missing-directive-argument","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}