Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hwillson committed Sep 29, 2018
2 parents 3d2ac10 + 62de207 commit 3e2417f
Show file tree
Hide file tree
Showing 56 changed files with 209 additions and 139 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
- Mutation errors are now properly returned as a render prop, when using
a default `errorPolicy` of `all`. <br/>
[@amacleay](https://github.com/amacleay) in [#2374](https://github.com/apollographql/react-apollo/pull/2374)
- `<Mutation />` `refetchQueries` triggered by name (string) will now use the correct variables. <br/>
[@fracmal](https://github.com/fracmak) in [#2422](https://github.com/apollographql/react-apollo/pull/2422)
- Remove `allowSyntheticDefaultImports` use. Typescript's
`allowSyntheticDefaultImports` compiler option is something we'd like to
start using, but we jumped the gun a bit by introducing it in
Expand Down
4 changes: 2 additions & 2 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Removed import
import includes from 'lodash.includes';
import fs from 'fs';
const includes = require('lodash.includes');
import * as fs from 'fs';

// Setup
const pr = danger.github.pr;
Expand Down
2 changes: 1 addition & 1 deletion examples/base/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';

Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import Character from './Character';
import { Episode } from './__generated__/types';

Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/src/Character.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { GetCharacterQuery, GetCharacterQueryVariables, Episode } from './__generated__/types';
import { GetCharacter as QUERY } from './queries';
import { Query } from 'react-apollo';
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { render } from 'react-dom';
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
Expand Down
42 changes: 0 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@
"@types/graphql": "14.0.1",
"@types/invariant": "2.2.29",
"@types/jest": "23.3.2",
"@types/lodash.flowright": "^3.5.4",
"@types/lodash.includes": "^4.3.4",
"@types/lodash.isequal": "^4.5.3",
"@types/lodash.times": "^4.3.4",
"@types/object-assign": "4.0.30",
"@types/prop-types": "15.5.5",
"@types/react": "16.4.14",
Expand Down
4 changes: 2 additions & 2 deletions src/ApolloConsumer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import ApolloClient from 'apollo-client';

const invariant = require('invariant');
Expand Down
4 changes: 2 additions & 2 deletions src/ApolloProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { Component } from 'react';
import ApolloClient from 'apollo-client';
import { DocumentNode } from 'graphql';
Expand Down
6 changes: 3 additions & 3 deletions src/Mutation.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import ApolloClient, { PureQueryOptions, ApolloError } from 'apollo-client';
import { DataProxy } from 'apollo-cache';
import invariant from 'invariant';
const invariant = require('invariant');
import { DocumentNode, GraphQLError } from 'graphql';
const shallowEqual = require('fbjs/lib/shallowEqual');

Expand Down
20 changes: 14 additions & 6 deletions src/Query.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import ApolloClient, {
ObservableQuery,
ApolloError,
Expand Down Expand Up @@ -286,18 +286,26 @@ export default class Query<TData = any, TVariables = OperationVariables> extends
private initializeQueryObservable(props: QueryProps<TData, TVariables>) {
const opts = this.extractOptsFromProps(props);
// save for backwards compat of refetcherQueries without a recycler
this.setOperations(opts);
this.queryObservable = this.client.watchQuery(opts);
}

private setOperations(props: QueryProps<TData, TVariables>) {
if (this.context!.operations) {
this.context!.operations!.set(this.operation!.name, {
query: opts.query,
variables: opts.variables,
query: props.query,
variables: props.variables,
});
}
this.queryObservable = this.client.watchQuery(opts);
}

private updateQuery(props: QueryProps<TData, TVariables>) {
// if we skipped initially, we may not have yet created the observable
if (!this.queryObservable) this.initializeQueryObservable(props);
if (!this.queryObservable) {
this.initializeQueryObservable(props);
} else {
this.setOperations(props);
}

this.queryObservable!.setOptions(this.extractOptsFromProps(props))
// The error will be passed to the child container, so we don't
Expand Down
4 changes: 2 additions & 2 deletions src/Subscriptions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import ApolloClient, { ApolloError } from 'apollo-client';
import { Observable } from 'apollo-link';

Expand Down
2 changes: 1 addition & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export * from './withApollo';
export * from './types';

// XXX remove in the next breaking semver change (3.0)
import compose from 'lodash.flowright';
const compose = require('lodash.flowright');
export { compose };
2 changes: 1 addition & 1 deletion src/component-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ApolloClient from 'apollo-client';
import invariant from 'invariant';
const invariant = require('invariant');

export interface CommonComponentProps {
client?: ApolloClient<Object>;
Expand Down
4 changes: 2 additions & 2 deletions src/getDataFromTree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

export interface Context {
[key: string]: any;
Expand Down Expand Up @@ -60,7 +60,7 @@ export function walkTree(
if (!element) {
return;
}

if (Array.isArray(element)) {
element.forEach(item => walkTree(item, context, visitor, newContext));
return;
Expand Down
2 changes: 1 addition & 1 deletion src/graphql.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
import { parser, DocumentType } from './parser';
import { OperationOption, DataProps, MutateProps } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/hoc-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
const invariant = require('invariant');

import { OperationVariables } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/mutation-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
const hoistNonReactStatics = require('hoist-non-react-statics');

Expand Down
2 changes: 1 addition & 1 deletion src/query-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { ApolloError } from 'apollo-client';
import { DocumentNode } from 'graphql';
const hoistNonReactStatics = require('hoist-non-react-statics');
Expand Down
2 changes: 1 addition & 1 deletion src/renderToStringWithData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement } from 'react';
import ReactDOM from 'react-dom/server';
import * as ReactDOM from 'react-dom/server';

import { default as getDataFromTree } from './getDataFromTree';

Expand Down
2 changes: 1 addition & 1 deletion src/subscription-hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { DocumentNode } from 'graphql';
const hoistNonReactStatics = require('hoist-non-react-statics');

Expand Down
2 changes: 1 addition & 1 deletion src/test-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import { print } from 'graphql/language/printer';
import { addTypenameToDocument } from 'apollo-utilities';
import isEqual from 'lodash.isequal';
const isEqual = require('lodash.isequal');

export interface MockedResponse {
request: GraphQLRequest;
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import ApolloClient from 'apollo-client';
import { DefaultOptions } from 'apollo-client/ApolloClient';
import { InMemoryCache as Cache } from 'apollo-cache-inmemory';
Expand Down
2 changes: 1 addition & 1 deletion src/withApollo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { OperationOption } from './types';
import ApolloConsumer from './ApolloConsumer';
import { ApolloClient } from 'apollo-client';
Expand Down
2 changes: 1 addition & 1 deletion test/client/ApolloConsumer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import ApolloClient from 'apollo-client';
import { InMemoryCache as Cache } from 'apollo-cache-inmemory';
import { ApolloLink } from 'apollo-link';
Expand Down
6 changes: 3 additions & 3 deletions test/client/ApolloProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { shallow } from 'enzyme';
import TestUtils from 'react-dom/test-utils';
import * as TestUtils from 'react-dom/test-utils';
import ApolloClient from 'apollo-client';
import { InMemoryCache as Cache } from 'apollo-cache-inmemory';
import { ApolloLink } from 'apollo-link';
Expand Down
Loading

0 comments on commit 3e2417f

Please sign in to comment.