{"record":{"id":"4c42f49162638b8c","repo":"facebook/relay","slug":"the-id-field-must-be-present-on-the-argument-th","errorCode":null,"errorMessage":"The __id field must be present on the argument. This indicates a bug in Relay.","messagePattern":"The __id field must be present on the argument\\. This indicates a bug in Relay\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/relay-runtime/mutations/createUpdatableProxy.js","lineNumber":257,"sourceCode":"      );\n    }\n  };\n}\n\nfunction createSetterForSingularLinkedField(\n  selection: ReaderLinkedField,\n  variables: Variables,\n  updatableProxyRootRecord: RecordProxy,\n  recordSourceProxy: RecordSourceProxy,\n) {\n  return function set(newValue: ?{__id: string, ...}) {\n    const newVariables = getArgumentValues(selection.args ?? [], variables);\n    if (newValue == null) {\n      updatableProxyRootRecord.setValue(newValue, selection.name, newVariables);\n    } else {\n      const {__id} = newValue;\n      if (__id == null) {\n        throw new Error(\n          'The __id field must be present on the argument. This indicates a bug in Relay.',\n        );\n      }\n      const newValueRecord = recordSourceProxy.get(__id);\n      if (newValueRecord == null) {\n        throw new Error(`Did not find item with data id ${__id} in the store.`);\n      }\n      updatableProxyRootRecord.setLinkedRecord(\n        newValueRecord,\n        selection.name,\n        newVariables,\n      );\n    }\n  };\n}\n\nfunction createGetterForPluralLinkedField(\n  selection: ReaderLinkedField,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/relay-runtime/mutations/createUpdatableProxy.js#L239-L275","documentation":"When assigning a singular linked field through an updatable proxy, the new value must carry a `__id` (data ID) so Relay can link the corresponding store record. A value without `__id` is not a valid record reference; Relay declares this an internal invariant violation.","triggerScenarios":"Calling `singularField.set(value)` with a raw object (e.g. a mutation response payload or inline object literal) that has no `__id`, instead of a record proxy from the store/updatable proxy.","commonSituations":"Assigning raw GraphQL response data directly in an updater; constructing `set({...})` with object literals; TypeScript types not narrowing away plain objects.","solutions":["Assign records obtained via `updatable.<field>.get()` or `store.get(id)` — never raw payload objects","If you have a data ID, do `store.get(id)` first and set the returned record","Copy needed fields from the raw object into a store record, then assign that record","If a genuine RecordProxy lacks `__id`, report it as a Relay bug"],"exampleFix":"// before\nupdatable.viewer.bestFriend.set(response.updateUser.bestFriend); // raw object\n// after\nconst friend = store.get(response.updateUser.bestFriend.id);\nupdatable.viewer.bestFriend.set(friend);","handlingStrategy":"type-guard","validationCode":"function isRecordProxyLike(v) {\n  return v != null && typeof v === 'object' && typeof v.__id === 'string' && v.__id.length > 0;\n}\nif (next != null && !isRecordProxyLike(next)) throw new TypeError('Singular setter requires a record proxy with __id');","typeGuard":"function isRecordRef(v: unknown): v is {__id: string} {\n  return typeof v === 'object' && v !== null && typeof (v as any).__id === 'string';\n}","tryCatchPattern":"try {\n  field.set(next);\n} catch (e) {\n  if (e.message.includes('__id field must be present')) throw new Error('Assign store records, not raw payload objects', {cause: e});\n  throw e;\n}","preventionTips":["Assign only records from updatable proxies or store.get(id)","Never pass inline object literals or raw responses to linked field setters","Convert payloads to store records before linking","TypeScript: type setter args as the proxy type so raw objects fail compilation"],"tags":["relay","updater","graphql","internal-bug"],"backgroundTag":"missing-data-id","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}