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

1.0.0 rc.2 #520

Merged
merged 10 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1",
"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.1",
"graphql-anywhere": "^2.0.0",
"graphql-tag": "^1.3.1",
"hoist-non-react-statics": "^1.2.0",
Expand Down
9 changes: 5 additions & 4 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it's not exported by Apollo Client yet. "Someone" forgot to export it. We'll add it in the next release.

} from 'apollo-client';

import {
Expand All @@ -45,15 +46,13 @@ 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?: 'network-only' | 'cache-first' | 'cache-only' | 'cache-and-network'; // update this to FetchPolicy
pollInterval?: number;
// deprecated
skip?: boolean;
Expand Down Expand Up @@ -428,7 +427,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