Skip to content

Commit

Permalink
Merge branch 'master' into feat/imperative-read-write
Browse files Browse the repository at this point in the history
  • Loading branch information
calebmer authored Feb 28, 2017
2 parents 97686e3 + 18b6780 commit 4103831
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
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
- Clear pollInterval in `ObservableQuery#stopPolling` so that resubscriptions don't start polling again [PR #1328](https://github.com/apollographql/apollo-client/pull/1328)
- Add direct cache manipulation read and write methods to provide the user the power to interact with Apollo’s GraphQL data representation outside of mutations. [PR #1310](https://github.com/apollographql/apollo-client/pull/1310)
- Clear pollInterval in `ObservableQuery#stopPolling` so that resubscriptions don't start polling again [PR #1328](https://github.com/apollographql/apollo-client/pull/1328)
- Update dependencies (Typescript 2.2.1, node typings, etc.) [PR #1332][https://github.com/apollographql/apollo-client/pull/1332]
- ...

### 0.9.0
- Prefer stale data over partial data in cases where a user would previously get an error. [PR #1306](https://github.com/apollographql/apollo-client/pull/1306)
Expand Down
5 changes: 2 additions & 3 deletions fetch-mock.typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

// Changes
// 1. Reference to isomorphic-fetch
// 2. Response -> IResponse
// 3. wrapping as a module
// 2. wrapping as a module

// Type definitions for fetch-mock 5.0.0
// Project: https://github.com/wheresrhys/fetch-mock
Expand Down Expand Up @@ -79,7 +78,7 @@ declare namespace FetchMock {
* Function(url, opts): A function that is passed the url and opts fetch()
is called with and that returns any of the responses listed above
*/
type MockResponse = IResponse | Promise<IResponse>
type MockResponse = Response | Promise<Response>
| number | Promise<number>
| string | Promise<string>
| Object | Promise<Object>
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
"devDependencies": {
"@types/benchmark": "^1.0.30",
"@types/chai": "^3.4.32",
"@types/chai-as-promised": "0.0.28",
"@types/lodash": "4.14.42",
"@types/chai-as-promised": "0.0.29",
"@types/lodash": "4.14.53",
"@types/mocha": "^2.2.31",
"@types/node": "^6.0.38",
"@types/promises-a-plus": "0.0.26",
"@types/node": "^7.0.5",
"@types/promises-a-plus": "0.0.27",
"@types/sinon": "^1.16.29",
"browserify": "^14.0.0",
"benchmark": "^2.1.3",
Expand All @@ -71,7 +71,7 @@
"es6-promise": "^4.0.4",
"fetch-mock": "^5.5.0",
"grunt": "1.0.1",
"grunt-tslint": "4.0.0",
"grunt-tslint": "4.0.1",
"gzip-size": "^3.0.0",
"isomorphic-fetch": "^2.2.1",
"istanbul": "^0.4.5",
Expand All @@ -85,15 +85,15 @@
"rxjs": "^5.0.0-beta.11",
"sinon": "^1.17.4",
"source-map-support": "^0.4.0",
"tslint": "4.4.2",
"typescript": "2.1.5",
"tslint": "4.5.0",
"typescript": "2.2.1",
"uglify-js": "^2.6.2",
"webpack": "^2.1.0-beta.28",
"webpack-bundle-analyzer": "^2.1.1"
},
"optionalDependencies": {
"@types/async": "^2.0.31",
"@types/isomorphic-fetch": "0.0.30",
"@types/isomorphic-fetch": "0.0.33",
"@types/graphql": "^0.8.0"
}
}
2 changes: 1 addition & 1 deletion src/transport/afterware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface AfterwareResponse {
response: IResponse;
response: Response;
options: RequestInit;
}

Expand Down
10 changes: 5 additions & 5 deletions src/transport/batchedNetworkInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class HTTPBatchedNetworkInterface extends HTTPFetchNetworkInterface {
Promise.all(middlewarePromises).then((requestsAndOptions: RequestAndOptions[]) => {
return this.batchedFetchFromRemoteEndpoint(requestsAndOptions)
.then(result => {
const httpResponse = result as IResponse;
const httpResponse = result as Response;

if (!httpResponse.ok) {
const httpError = new Error(`Network request failed with status ${httpResponse.status} - "${httpResponse.statusText}"`);
Expand All @@ -82,19 +82,19 @@ export class HTTPBatchedNetworkInterface extends HTTPFetchNetworkInterface {
}

type ResponseAndOptions = {
response: IResponse;
response: Response;
options: RequestInit;
};

const afterwaresPromises: ResponseAndOptions[] = responses.map((response: IResponse, index: number) => {
const afterwaresPromises: ResponseAndOptions[] = responses.map((response: Response, index: number) => {
return this.applyAfterwares({
response,
options: requestsAndOptions[index].options,
});
});

Promise.all(afterwaresPromises).then((responsesAndOptions: ResponseAndOptions[]) => {
const results: Array<IResponse> = [];
const results: Array<Response> = [];
responsesAndOptions.forEach((result) => {
results.push(result.response);
});
Expand All @@ -111,7 +111,7 @@ export class HTTPBatchedNetworkInterface extends HTTPFetchNetworkInterface {

private batchedFetchFromRemoteEndpoint(
requestsAndOptions: RequestAndOptions[],
): Promise<IResponse> {
): Promise<Response> {
const options: RequestInit = {};

// Combine all of the options given by the middleware into one object.
Expand Down
8 changes: 4 additions & 4 deletions src/transport/networkInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface RequestAndOptions {
}

export interface ResponseAndOptions {
response: IResponse;
response: Response;
options: RequestInit;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ export class HTTPFetchNetworkInterface implements NetworkInterface {
public fetchFromRemoteEndpoint({
request,
options,
}: RequestAndOptions): Promise<IResponse> {
}: RequestAndOptions): Promise<Response> {
return fetch(this._uri, {
...this._opts,
body: JSON.stringify(printRequest(request)),
Expand All @@ -179,11 +179,11 @@ export class HTTPFetchNetworkInterface implements NetworkInterface {
options,
}).then( (rao) => this.fetchFromRemoteEndpoint.call(this, rao))
.then(response => this.applyAfterwares({
response: response as IResponse,
response: response as Response,
options,
}))
.then(({ response }) => {
const httpResponse = response as IResponse;
const httpResponse = response as Response;

if (!httpResponse.ok) {
const httpError = new Error(`Network request failed with status ${response.status} - "${response.statusText}"`);
Expand Down
2 changes: 2 additions & 0 deletions test/batchedNetworkInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import gql from 'graphql-tag';

import 'whatwg-fetch';

declare var fetch: any;

describe('HTTPBatchedNetworkInterface', () => {
// Helper method that tests a roundtrip given a particular set of requests to the
// batched network interface and the
Expand Down
2 changes: 2 additions & 0 deletions test/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ import observableToPromise from './util/observableToPromise';

import { cloneDeep, assign } from 'lodash';

declare var fetch: any;

// make it easy to assert with promises
chai.use(chaiAsPromised);

Expand Down

0 comments on commit 4103831

Please sign in to comment.