Open
Description
Issue workflow progress
Describe the bug
- A spread operator is being used to merge the previous context and the new context. If the context is a class and there are methods in its prototype, it will lose the prototype methods during this merging.
- Code from https://github.com/n1ru4l/envelop/blob/main/packages/plugins/execute-subscription-event/src/index.ts
onSubscribe({ args, setSubscribeFn }) {
const executeNew = makeExecute(async executionArgs => {
const context = await createContext({ args });
try {
return await execute({
...executionArgs,
// GraphQL.js 16 changed the type of contextValue to unknown
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contextValue: { ...executionArgs.contextValue, ...context?.contextPartial },
});
} finally {
context?.onEnd?.();
}
});
setSubscribeFn(subscribe(executeNew));
},
Expected behavior
- The object's property should be replaced with a new value, rather than merging the objects using the spread operator.
Metadata
Metadata
Assignees
Labels
No labels