{"record":{"id":"5f24fa0531f8dfb7","repo":"facebook/relay","slug":"unexpected-graphqlmoduledependency","errorCode":null,"errorMessage":"Unexpected GraphQLModuleDependency","messagePattern":"Unexpected GraphQLModuleDependency","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/printer.rs","lineNumber":932,"sourceCode":"                        write!(f, \"\\\\\\\"{name}\\\\\\\":\")?;\n                        write_constant_value(f, builder, value)?;\n                        f.push(',');\n                    }\n                    if !obj.is_empty() {\n                        f.pop();\n                    }\n                    f.push('}');\n                    Ok(())\n                }\n            }\n        }\n        Primitive::Null | Primitive::SkippableNull => {\n            f.push_str(\"null\");\n            Ok(())\n        }\n        Primitive::StorageKey(_, _) => panic!(\"Unexpected StorageKey\"),\n        Primitive::RawString(_) => panic!(\"Unexpected RawString\"),\n        Primitive::GraphQLModuleDependency(_) => panic!(\"Unexpected GraphQLModuleDependency\"),\n        Primitive::JSModuleDependency { .. } => panic!(\"Unexpected JSModuleDependency\"),\n        Primitive::ResolverModuleReference { .. } => panic!(\"Unexpected ResolverModuleReference\"),\n        Primitive::PropertyAccessor(_) => panic!(\"Unexpected PropertyAccessor\"),\n        Primitive::DynamicImport { .. } => panic!(\"Unexpected DynamicImport\"),\n        Primitive::RelayResolverModel { .. } => panic!(\"Unexpected RelayResolver\"),\n    }\n}\n","sourceCodeStart":914,"sourceCodeEnd":940,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/printer.rs#L914-L940","documentation":"Primitive::GraphQLModuleDependency wraps a @module/@match module dependency and is consumed by dedicated module-import writers, not by write_constant_value. If such a dependency appears where a plain constant value is being printed (argument literals, lists, object values), the printer panics because it cannot serialize a module reference as a literal.","triggerScenarios":"A @module/@match-produced GraphQLModuleDependency primitive flowing into an argument value or constant position — e.g. using a module fragment spread/dependency as (or inside) a printed argument rather than as a selection.","commonSituations":"Misusing @module/@match so the module dependency lands in an argument instead of a selection; custom transforms building module dependencies inside argument values; upgrading the compiler and old IR shapes now reaching write_constant_value.","solutions":["Move the @module usage to the selection position (an inline fragment with @module spreading the module fragment) instead of an argument","Ensure arguments only contain literal values; module references must go through the module import path (write_module_import) not write_constant_value","Audit custom transforms that place GraphQLModuleDependency primitives in argument values and remove them","Update Relay compiler if the IR no longer matches what the printer expects"],"exampleFix":"// before\n... on Post @module(as: \"User_post\") { arg: someModule }\n// after\n... on Post @module(as: \"User_post\") { someField }  // module spreads as selections, not arguments","handlingStrategy":"validation","validationCode":"function assertNoModuleDepsInArgs(doc) {\n  visit(doc, {\n    Argument(node) {\n      if (referencesModuleDirective(node.value)) {\n        throw new Error(`Module dependencies cannot be used in argument '${node.name.value}'`);\n      }\n    }\n  });\n}","typeGuard":"const isModuleRef = (v) => typeof v === 'string' && v.includes('@module');","tryCatchPattern":"try {\n  generateArtifacts();\n} catch (e) {\n  if (String(e).includes('Unexpected GraphQLModuleDependency')) {\n    // move the @module usage from arguments into selections\n  }\n  throw e;\n}","preventionTips":["Use @module only on inline fragments (selections), never in arguments","Keep argument values strictly literal","Audit custom transforms for module dependencies in value slots","Update the compiler as a unit with runtime packages"],"tags":["compiler","codegen","graphql-module","primitive"],"backgroundTag":"unexpected-primitive-kind","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}