Fields of a query that had arguments but no variables supplied would receive undefined variables in the policy event rather than {}. Since the empty object would be needed to retrieve the field and its values from the cache using an access like:
CreateEmployeeResponse: {
onWrite: {
EmployeesResponse: (
{ modify, readField },
{ fieldName, parent }
) => {
// assuming the field createEmployee has empty arguments and is stored as createEmployee({})
const createEmployeeResponse: any = readField({
fieldName: parent.fieldName, // createEmployee
from: parent.ref, // { __ref: "ROOT_QUERY" }
args: parent.variables // Must be {} to read createEmployee({}) and not createEmployee
});
},
},
},
Now, if the field the policy event is run on has arguments, we pass {} as the variables to the event so that it is able to access the field in the cache using the provided variables.
Fields of a query that had arguments but no variables supplied would receive
undefined
variables in the policy event rather than{}
. Since the empty object would be needed to retrieve the field and its values from the cache using an access like:Now, if the field the policy event is run on has arguments, we pass
{}
as the variables to the event so that it is able to access the field in the cache using the provided variables.