{
componentWillReact() {
if (this.props.appState.first === 1) {
- this.props.data.refetch({ first: this.props.appState.first });
+ this.props.data.refetch({ first: this.props.appState.first }).catch((e) => {
+ console.error(e);
+ });
}
}
componentWillReceiveProps(nextProps) {
diff --git a/test/react-web/client/libraries/redux-1.test.tsx b/test/react-web/client/libraries/redux-1.test.tsx
index be75558e34..e9c89bc671 100644
--- a/test/react-web/client/libraries/redux-1.test.tsx
+++ b/test/react-web/client/libraries/redux-1.test.tsx
@@ -34,7 +34,7 @@ describe('redux integration', () => {
{ request: { query, variables: variables2 }, result: { data: data2 } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper;
function counter(state = 1, action) {
@@ -93,7 +93,7 @@ describe('redux integration', () => {
{ request: { query, variables }, result: { data } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
// Typscript workaround
const apolloReducer = client.reducer() as () => any;
@@ -167,7 +167,7 @@ describe('redux integration', () => {
{ request: { query, variables: variables2 }, result: { data: data2 } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper;
function counter(state = 1, action) {
diff --git a/test/react-web/client/libraries/redux-2.test.tsx b/test/react-web/client/libraries/redux-2.test.tsx
index 5a776e1738..2a2a976d15 100644
--- a/test/react-web/client/libraries/redux-2.test.tsx
+++ b/test/react-web/client/libraries/redux-2.test.tsx
@@ -48,7 +48,7 @@ describe('redux integration', () => {
{ request: { query, variables }, result: { data } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper;
// Typscript workaround
@@ -133,7 +133,7 @@ describe('redux integration', () => {
{ request: { query, variables: variables2 }, result: { data: data2 } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper;
function counter(state = 1, action) {
@@ -197,7 +197,7 @@ describe('redux integration', () => {
{ request: { query, variables: variables2 }, result: { data: data2 } }
);
- const client = new ApolloClient({ networkInterface });
+ const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper;
function counter(state = 1, action) {
diff --git a/test/react-web/server/index.test.tsx b/test/react-web/server/index.test.tsx
index 41eddac900..33f5bd7fa6 100644
--- a/test/react-web/server/index.test.tsx
+++ b/test/react-web/server/index.test.tsx
@@ -39,7 +39,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query)(({ data }) => (
{data.loading ? 'loading' : data.currentUser.firstName}
@@ -61,7 +61,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query)(({ data }) => (
{data.loading ? 'loading' : data.currentUser.firstName}
@@ -88,7 +88,7 @@ describe('SSR', () => {
{ request: { query: idQuery }, result: { data: idData }, delay: 50 },
{ request: { query: userQuery, variables }, result: { data: userData }, delay: 50 },
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const withId = graphql(idQuery);
const withUser = graphql(userQuery, {
@@ -116,7 +116,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query, { options: { skip: true }})(({ data }) => (
{data.loading ? 'loading' : 'skipped'}
@@ -139,7 +139,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query, { skip: true })(({ data }) => (
{!data ? 'skipped' : 'dang'}
@@ -161,7 +161,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query)(({ data }) => (
{data.loading ? 'loading' : data.currentUser.firstName}
@@ -185,7 +185,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query, variables }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const Element = graphql(query, { name: 'user' })(({ user }) => (
{user.loading ? 'loading' : user.currentUser.firstName}
@@ -209,7 +209,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query, variables }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
@graphql(query, { name: 'user' })
class Element extends React.Component {
@@ -247,7 +247,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query, variables }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const Element = graphql(query, {
name: 'user',
@@ -279,7 +279,7 @@ describe('SSR', () => {
{ request: { query }, result: { data: data1 }, delay: 5 },
{ request: { query: mutation }, result: { data: mutationData }, delay: 5 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const withQuery = graphql(query, {
options: (ownProps) => ({ ssr: true }),
@@ -331,7 +331,7 @@ describe('SSR', () => {
{ request: { query }, result: { data: data1 }, delay: 5 },
{ request: { query: mutation }, result: { data: mutationData }, delay: 5 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const withQuery = graphql(query, {
props: ({ ownProps, data }) => {
@@ -366,7 +366,7 @@ describe('SSR', () => {
const networkInterface = mockNetworkInterface(
{ request: { query }, result: { data }, delay: 50 }
);
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const WrappedElement = graphql(query)(({ data }) => (
{data.loading ? 'loading' : data.currentUser.firstName}
@@ -416,7 +416,9 @@ describe('SSR', () => {
// XXX mock all queries
it('should work on a non trivial example', function() {
// this.timeout(10000);
- const networkInterface = createNetworkInterface('http://graphql-swapi.parseapp.com/');
+ const networkInterface = createNetworkInterface({
+ uri: 'http://graphql-swapi.parseapp.com/',
+ });
const apolloClient = new ApolloClient({ networkInterface });
@graphql(gql`
@@ -516,13 +518,13 @@ describe('SSR', () => {
});
it('should work with queries that use fragments', function() {
- const query = gql`{ currentUser { ...userInfo } }`;
+ const query = gql`{ currentUser { __typename, ...userInfo } }`;
const userInfoFragment = createFragment(gql`fragment userInfo on User { firstName, lastName }`);
- const data = { currentUser: { firstName: 'John', lastName: 'Smith' } };
+ const data = { currentUser: { __typename: 'User', firstName: 'John', lastName: 'Smith' } };
const networkInterface = {
query: () => Promise.resolve({ data }),
};
- const apolloClient = new ApolloClient({ networkInterface });
+ const apolloClient = new ApolloClient({ networkInterface, addTypename: false });
const UserPage = graphql(query, {
options: {