-
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
Adding typescript definition for 'this' on Middleware and Afterware apply functions. #1372
Conversation
vangorra
commented
Mar 7, 2017
- If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
- Make sure all of the significant new logic is covered by tests
- Rebase your changes on master so that they can be merged easily
- Make sure all tests and linter rules pass
- Update CHANGELOG.md with your change
- Add your name and email to the AUTHORS file (optional)
- If this was a change that affects the external API, update the docs and post a link to the PR in the discussion
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.
Thanks for the PR @vangorra ! Just a minor change and a few clarifications needed. 👍
CHANGELOG.md
Outdated
@@ -10,7 +10,7 @@ Expect active development and potentially significant breaking changes in the `0 | |||
- Fix: make sure maybeDeepFreeze is called on results returned from setVariables and refetch [PR #1362](https://github.com/apollographql/apollo-client/pull/1362) | |||
- Fix: use setTimeout to throw uncaught errors in observer.next and observer.error[PR #1367](https://github.com/apollographql/apollo-client/pull/1367) | |||
- Remove returnPartialData option [PR #1370](https://github.com/apollographql/apollo-client/pull/1370) | |||
|
|||
- Update TypeScript Middleware and Afterware interfaces to include a datatype for 'this' in apply function. |
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.
Make sure to add the PR number here!
src/transport/afterware.ts
Outdated
@@ -13,5 +15,5 @@ export interface BatchAfterwareResponse { | |||
} | |||
|
|||
export interface BatchAfterwareInterface { | |||
applyBatchAfterware(response: BatchAfterwareResponse, next: Function): any; | |||
applyBatchAfterware(this: NetworkInterface, response: BatchAfterwareResponse, next: Function): any; |
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.
Is this the correct type or could it be more specific (BatchNetworkInterface)?
src/transport/middleware.ts
Outdated
|
||
export interface MiddlewareRequest { | ||
request: Request; | ||
options: RequestInit; | ||
} | ||
|
||
export interface MiddlewareInterface { | ||
applyMiddleware(request: MiddlewareRequest, next: Function): void; | ||
applyMiddleware(this: NetworkInterface, request: MiddlewareRequest, next: Function): void; |
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.
Also this type. Could it be more specific?
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.
Changes made.
Looks great, thanks! |