{"record":{"id":"09a2aaac94c5439e","repo":"facebook/relay","slug":"field-has-supported-arg-but-missing-from-the-sche","errorCode":null,"errorMessage":"field has supported arg, but missing from the schema","messagePattern":"field has supported arg, but missing from the schema","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-transforms/src/match_/hash_supported_argument.rs","lineNumber":128,"sourceCode":"}\n\nimpl HashSupportedArgumentTransform<'_> {\n    /// Returns true iff the field is supplied with a `supported` arg and that\n    /// arg has a type of `[string]` (potentially non-nullable somewhere).\n    fn has_match_supported_arg(&self, field: &LinkedField) -> bool {\n        if field\n            .arguments\n            .named(MATCH_CONSTANTS.supported_arg)\n            .is_none()\n        {\n            return false;\n        }\n        let supported_arg_def = self\n            .schema\n            .field(field.definition.item)\n            .arguments\n            .named(MATCH_CONSTANTS.supported_arg)\n            .expect(\"field has supported arg, but missing from the schema\");\n\n        if let TypeReference::List(item_type) = supported_arg_def.type_.nullable_type()\n            && let TypeReference::Named(item_type_name) = item_type.nullable_type()\n        {\n            return self.schema.is_string(*item_type_name);\n        }\n        false\n    }\n}\n\n#[derive(Debug, Error, serde::Serialize)]\n#[serde(tag = \"type\")]\npub enum HashSupportedArgumentError {\n    #[error(\n        \"Variables cannot be passed to the `supported` argument for data driven dependency fields, please use literal values like `\\\"ExampleValue\\\"`.\"\n    )]\n    NonStaticSupportedArg,\n}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-transforms/src/match_/hash_supported_argument.rs#L110-L146","documentation":"has_match_supported_arg first looks at a field's IR arguments for the @match supported argument, and when present expects the schema's field definition to declare the same argument (schema.field(...).arguments.named(...)). This expect fires when the argument appears in the compiled usage but is absent from the schema definition — the schema and the document disagree.","triggerScenarios":"Calling transform_linked_field on a field whose arguments contain the supported_arg while the schema definition of that field lacks it — typically after schema regeneration, a partial schema merge, or compiling against stale artifacts.","commonSituations":"Schema regenerated without the supported argument input field while cached compiled artifacts still reference it; codegen ran against an older schema; splitting/merging schema files dropped the argument definition; the argument is declared on a different field variant than the one resolved.","solutions":["Add the supported argument to the field's definition in the schema (e.g. viewer(filters: [MyEnum!]): User) so it matches the IR.","Regenerate/rebuild schema artifacts so the compiled program and schema come from the same run.","Clear stale build caches (relay build artifacts, persisted queries) and recompile.","Check for duplicate field definitions where only one variant declares the argument but the transform resolves the other.","Ensure the argument's type is a List of a Named type — the code immediately expects that shape via TypeReference::List/Named."],"exampleFix":"// before (schema)\ntype Query { viewer: User }\n// after (schema)\ntype Query {\n  viewer(supportedLocales: [Language!]): User\n}","handlingStrategy":"validation","validationCode":"function schemaDeclaresSupportedArg(schema, fieldDefinition, argName) {\n  return Boolean(\n    fieldDefinition?.arguments?.some(\n      a => a.name === argName &&\n      a.type.toString().match(/\\[.+!?!?\\]/) // List of a named type\n    )\n  );\n}\n// build/validate schema first:\n// if (!schemaDeclaresSupportedArg(schema, schema.getQueryType().getFields().viewer, 'supportedLocales')) throw ...","typeGuard":"function hasNamedListArg(fieldDef, argName) {\n  const arg = fieldDef?.arguments?.find(a => a.name === argName);\n  if (!arg) return false;\n  return /\\[\\s*\\w+\\s*!?!?\\s*\\]/.test(String(arg.type));\n}","tryCatchPattern":"try {\n  program = applyMatchTransform(program);\n} catch (e) {\n  if (String(e.message).includes('missing from the schema')) {\n    throw new Error(`Schema/document mismatch: declare the supported argument in the schema for field used with @match (source: ${e.message})`);\n  }\n  throw e;\n}","preventionTips":["Always declare the supported argument in the schema, not just in queries.","Regenerate schema artifacts and recompile together; never mix schema generations.","Clear stale build caches after schema changes.","Validate that the argument type is a List of a Named type before running @match transforms."],"tags":["relay-compiler","graphql","schema-mismatch","invariant","match-transform"],"backgroundTag":"schema-definition-mismatch","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}