-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
The variables
option passed to sendVariableValues.transform
is the exact object used in query execution (direct or gateway), so if you mutate it instead of just returning a copied object, you will surprisingly affect query execution. The docs even encourage you to do this:
The function should modify or delete necessary values in the variables map and return the result.
At the very least we should change the docs to tell you to not mutate the argument!
We may also want to do one or both of:
- Using something like Suggestion: DeepReadonly<T> type microsoft/TypeScript#13923 to discourage TypeScript users from mutating the argument
- Doing some sort of clone (
JSON.parse(JSON.stringify())
?) on the variables that are passed in. This approach has a performance impact and could cause problems if somehow a variable's semantics aren't preserved through this clone process (though given that what happens to the thing returned bytransform
is that it gets JSON.stringify'd, maybe this isn't worth stressing about)
andrewl913 and arjen1981
Metadata
Metadata
Assignees
Labels
No labels