protocol RecordProxy
A RecordProxy
provides API reading and updating the fields of a particular record in the Relay store. A RecordProxy
can be obtained from a RecordSourceSelectorProxy or another RecordProxy
when updating the store after a mutation.
var dataID: DataID { get }
Returns the ID of the record.
All records have a unique ID in the store. If the record has an id
field, that value will be used as the ID. Otherwise, Relay will choose a client-side ID and use that.
<aside>
⚠️ Because Relay uses that id
field as a store-wide ID, it's important that you don't use the same IDs for two different values of different types. Your IDs must be globally unique, not just unique within a particular type. One way to do this is to include the type name or an abbreviation of it as part of the ID.
</aside>
var typeName: String { get }
Returns the name of the schema type for the record.
Every record in the store belongs to one of the types defined in your GraphQL schema.
subscript(
_ name: String,
args args: VariableDataConvertible? = nil
) -> Any? { get set }
You can use subscripts to read and write scalar fields of a record.
If the field has arguments, those should be passed to the subscript as well. This can be an ordinary Swift dictionary:
record["name", args: ["language": "en"]] = "hello world"
mutating func copyFields(from record: RecordProxy)
Copies all of the fields from record
into self
.
Any fields not present in record