Skip to content

Commit

Permalink
Merge pull request #1372 from vangorra/tsdef_fix
Browse files Browse the repository at this point in the history
Adding typescript definition for 'this' on Middleware and Afterware apply functions.
  • Loading branch information
Sashko Stubailo authored Mar 14, 2017
2 parents 82a846c + f77d64c commit 9fd0bdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Expect active development and potentially significant breaking changes in the `0.x` track. We'll try to be diligent about releasing a `1.0` version in a timely fashion (ideally within 3 to 6 months), to signal the start of a more stable API.

### vNEXT
- Fix: Update TypeScript Middleware and Afterware interfaces to include a datatype for 'this' in apply function. [PR #1372](https://github.com/apollographql/apollo-client/pull/1372)

### 1.0.0-rc.2
- throw error if deprecated options are being used [PR #1396](https://github.com/apollographql/apollo-client/pull/1396)
Expand Down Expand Up @@ -520,4 +521,4 @@ This release has a minor version bump, which means npm will not automatically up

### v0.1.0

Initial release. We didn't track changes before this version.
Initial release. We didn't track changes before this version.
7 changes: 5 additions & 2 deletions src/transport/afterware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { HTTPFetchNetworkInterface } from './networkInterface';
import { HTTPBatchedNetworkInterface } from './batchedNetworkInterface';

export interface AfterwareResponse {
response: Response;
options: RequestInit;
}

export interface AfterwareInterface {
applyAfterware(response: AfterwareResponse, next: Function): any;
applyAfterware(this: HTTPFetchNetworkInterface, response: AfterwareResponse, next: Function): any;
}

export interface BatchAfterwareResponse {
Expand All @@ -13,5 +16,5 @@ export interface BatchAfterwareResponse {
}

export interface BatchAfterwareInterface {
applyBatchAfterware(response: BatchAfterwareResponse, next: Function): any;
applyBatchAfterware(this: HTTPBatchedNetworkInterface, response: BatchAfterwareResponse, next: Function): any;
}
8 changes: 5 additions & 3 deletions src/transport/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Request } from './networkInterface';
import { Request, HTTPFetchNetworkInterface } from './networkInterface';
import { HTTPBatchedNetworkInterface } from './batchedNetworkInterface';


export interface MiddlewareRequest {
request: Request;
options: RequestInit;
}

export interface MiddlewareInterface {
applyMiddleware(request: MiddlewareRequest, next: Function): void;
applyMiddleware(this: HTTPFetchNetworkInterface, request: MiddlewareRequest, next: Function): void;
}

export interface BatchMiddlewareRequest {
Expand All @@ -15,5 +17,5 @@ export interface BatchMiddlewareRequest {
}

export interface BatchMiddlewareInterface {
applyBatchMiddleware(request: BatchMiddlewareRequest, next: Function): void;
applyBatchMiddleware(this: HTTPBatchedNetworkInterface, request: BatchMiddlewareRequest, next: Function): void;
}

0 comments on commit 9fd0bdb

Please sign in to comment.