-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix operation.setContext() type #11756
Fix operation.setContext() type #11756
Conversation
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
🦋 Changeset detectedLatest commit: d2c81dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
540ef79
to
0f37e96
Compare
While we're at it, could you please also add these adjustments? --- a/src/link/utils/createOperation.ts
+++ b/src/link/utils/createOperation.ts
@@ -5,14 +5,14 @@ export function createOperation(
operation: GraphQLRequest
): Operation {
let context = { ...starting };
- const setContext = (next: any) => {
+ const setContext: Operation["setContext"] = (next) => {
if (typeof next === "function") {
context = { ...context, ...next(context) };
} else {
context = { ...context, ...next };
}
};
- const getContext = () => ({ ...context });
+ const getContext: Operation["getContext"] = () => ({ ...context });
Object.defineProperty(operation, "setContext", {
enumerable: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, this is a great improvement!
Just so you're prepared for it: This PR will probably sit for a week or two, since we're essentially in a code freeze on the 3.9 branch as 3.10 is currently in RC state.
Co-authored-by: Lenz Weber-Tronic <mail@lenzw.de>
a53e479
to
a9d6bf5
Compare
Just made the adjustments. Thanks! No rush. |
I noticed couple issues with the
Operation.setContext()
types that I try to fix in this PR:void
and does not returnDefaultContext