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

Commit

Permalink
Merge pull request #520 from apollographql/1.0.0-rc.1
Browse files Browse the repository at this point in the history
1.0.0 rc.2
  • Loading branch information
helfer authored Mar 10, 2017
2 parents 42962b1 + 5fe88d8 commit 39ef50a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Expect active development and potentially significant breaking changes in the `0

### vNext

### 1.0.0-rc.1
- Update dependency to Apollo Client 1.0.0-rc.1 [PR #520](https://github.com/apollographql/react-apollo/pull/520)

### 0.13.3
- Make sure that the cached rendered element has the correct type before returning it. [PR #505](https://github.com/apollographql/react-apollo/pull/505)
- Move constructor initializing of props to componentWillMount. [PR #506](https://github.com/apollographql/react-apollo/pull/506) ([Issue #509](https://github.com/apollographql/react-apollo/issues/509)).
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "react-apollo",
"version": "0.13.3",
"version": "1.0.0-rc.2",
"description": "React data container for Apollo Client",
"main": "lib/index.js",
"browser": "lib/browser.js",
"typings": "lib/index.d.ts",
"scripts": {
"deploy": "npm run compile && npm test && npm publish",
"test": "jest",
"test": "npm run compile && jest",
"testonly": "jest",
"test-watch": "jest --watch",
"posttest": "npm run lint",
"filesize": "npm run compile:browser && ./scripts/filesize.js --file=./dist/index.min.js --maxGzip=20",
Expand Down Expand Up @@ -128,7 +129,7 @@
"uglify-js": "^2.6.2"
},
"dependencies": {
"apollo-client": "^0.9.0 || ^0.10.0",
"apollo-client": "^1.0.0-rc.2",
"graphql-anywhere": "^2.0.0",
"graphql-tag": "^1.3.1",
"hoist-non-react-statics": "^1.2.0",
Expand Down
10 changes: 5 additions & 5 deletions src/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ApolloClient, {
ApolloStore,
ApolloQueryResult,
ApolloError,
FetchPolicy,
} from 'apollo-client';

import {
Expand All @@ -45,15 +46,12 @@ export declare interface MutationOptions {
variables?: Object;
optimisticResponse?: Object;
updateQueries?: MutationQueryReducersMap;
forceFetch?: boolean;
}

export declare interface QueryOptions {
ssr?: boolean;
variables?: { [key: string]: any };
forceFetch?: boolean;
returnPartialData?: boolean;
noFetch?: boolean;
fetchPolicy?: FetchPolicy;
pollInterval?: number;
// deprecated
skip?: boolean;
Expand Down Expand Up @@ -428,7 +426,9 @@ export default function graphql(

const opts = this.calculateOptions() as any;
if (opts.ssr === false) return false;
if (opts.forceFetch) delete opts.forceFetch; // ignore force fetch in SSR;
if (opts.fetchPolicy === 'network-only') {
opts.fetchPolicy = 'cache-first'; // ignore force fetch in SSR;
}

const observable = this.client.watchQuery(assign({ query: document }, opts));
const result = observable.currentResult();
Expand Down
14 changes: 7 additions & 7 deletions test/react-web/client/graphql/queries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ describe('queries', () => {

let hasSkipped = false;
let hasRequeried = false;
@graphql(query, { options: ({ skip }) => ({ skip, forceFetch: true }) })
@graphql(query, { options: ({ skip }) => ({ skip, fetchPolicy: 'network-only' }) })
class Container extends React.Component<any, any> {8
componentWillReceiveProps(newProps) {
if (newProps.skip) {
Expand Down Expand Up @@ -814,7 +814,7 @@ describe('queries', () => {
const client = new ApolloClient({ networkInterface, addTypename: false });

@graphql(query, {
options: (props) => ({ variables: props, returnPartialData: count === 0 }),
options: (props) => ({ variables: props, fetchPolicy: count === 0 ? 'cache-and-network' : 'cache-first' }),
})
class Container extends React.Component<any, any> {
componentWillReceiveProps({ data }) {
Expand Down Expand Up @@ -1032,7 +1032,7 @@ describe('queries', () => {
const client = new ApolloClient({ networkInterface, addTypename: false });

let count = 0;
@graphql(query, { options() { return { variables }; } })
@graphql(query, { options() { return { variables, notifyOnNetworkStatusChange: false }; } })
class Container extends React.Component<any, any> {8
componentWillReceiveProps(props) {
count += 1;
Expand Down Expand Up @@ -1489,7 +1489,7 @@ describe('queries', () => {
const client = new ApolloClient({ networkInterface, addTypename: false });

let count = 0;
const Container = graphql(query, { options: () => ({ pollInterval: 75 }) })(() => {
const Container = graphql(query, { options: () => ({ pollInterval: 75, notifyOnNetworkStatusChange: false }) })(() => {
count++;
return null;
});
Expand Down Expand Up @@ -1849,7 +1849,7 @@ describe('queries', () => {
const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper, app, count = 0;

@graphql(query, { options: { pollInterval: 10 }})
@graphql(query, { options: { pollInterval: 10, notifyOnNetworkStatusChange: false }})
class Container extends React.Component<any, any> {
componentWillReceiveProps(props) {
if (count === 1) { // has data
Expand All @@ -1873,7 +1873,7 @@ describe('queries', () => {
wrapper = mount(app);
});

it('correctly sets loading state on remounted forcefetch', (done) => {
it('correctly sets loading state on remounted network-only query', (done) => {
const query = gql`query pollingPeople { allPeople(first: 1) { people { name } } }`;
const data = { allPeople: { people: [ { name: 'Darth Skywalker' } ] } };
const networkInterface = mockNetworkInterface(
Expand All @@ -1886,7 +1886,7 @@ describe('queries', () => {
const client = new ApolloClient({ networkInterface, addTypename: false });
let wrapper, app, count = 0;

@graphql(query, { options: { forceFetch: true }})
@graphql(query, { options: { fetchPolicy: 'network-only' }})
class Container extends React.Component<any, any> {
componentWillMount() {
if (count === 1) {
Expand Down
4 changes: 2 additions & 2 deletions test/react-web/server/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('SSR', () => {
});
});

it('should allow forceFetch as an option and still render prefetched data', () => {
it('should allow network-only fetchPolicy as an option and still render prefetched data', () => {

const query = gql`{ currentUser { firstName } }`;
const data = { currentUser: { firstName: 'James' } };
Expand All @@ -172,7 +172,7 @@ describe('SSR', () => {
);
const apolloClient = new ApolloClient({ networkInterface, addTypename: false });

const WrappedElement = graphql(query, { options: { forceFetch: true }})(({ data }) => (
const WrappedElement = graphql(query, { options: { fetchPolicy: 'network-only' }})(({ data }) => (
<div>{data.loading ? 'loading' : data.currentUser.firstName}</div>
));

Expand Down

0 comments on commit 39ef50a

Please sign in to comment.