File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { gql , graphql } from 'react-apollo'
1+ import { graphql } from 'react-apollo'
2+ import gql from 'graphql-tag'
23import ErrorMessage from './ErrorMessage'
34import PostUpvoter from './PostUpvoter'
45
Original file line number Diff line number Diff line change 11import React from 'react'
2- import { gql , graphql } from 'react-apollo'
2+ import { graphql } from 'react-apollo'
3+ import gql from 'graphql-tag'
34
45function PostUpvoter ( { upvote, votes, id } ) {
56 return (
Original file line number Diff line number Diff line change 1- import { gql , graphql } from 'react-apollo'
1+ import { graphql } from 'react-apollo'
2+ import gql from 'graphql-tag'
23
34function Submit ( { createPost } ) {
45 function handleSubmit ( e ) {
Original file line number Diff line number Diff line change 1- import { ApolloClient , createNetworkInterface } from 'react-apollo'
1+ import { ApolloClient } from 'apollo-client'
2+ import { HttpLink } from 'apollo-link-http'
3+ import { InMemoryCache } from 'apollo-cache-inmemory'
24import fetch from 'isomorphic-fetch'
35
46let apolloClient = null
@@ -10,14 +12,15 @@ if (!process.browser) {
1012
1113function create ( initialState ) {
1214 return new ApolloClient ( {
13- initialState ,
15+ connectToDevTools : process . browser ,
1416 ssrMode : ! process . browser , // Disables forceFetch on the server (so queries are only run once)
15- networkInterface : createNetworkInterface ( {
17+ link : new HttpLink ( {
1618 uri : 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn' , // Server URL (must be absolute)
17- opts : { // Additional fetch() options like `credentials` or `headers`
18- credentials : 'same-origin'
19+ opts : {
20+ credentials : 'same-origin' // Additional fetch() options like `credentials` or `headers`
1921 }
20- } )
22+ } ) ,
23+ cache : new InMemoryCache ( ) . restore ( initialState || { } ) ,
2124 } )
2225}
2326
Original file line number Diff line number Diff line change @@ -48,12 +48,9 @@ export default ComposedComponent => {
4848 Head . rewind ( )
4949
5050 // Extract query data from the Apollo store
51- const state = apollo . getInitialState ( )
52-
5351 serverState = {
5452 apollo : {
55- // Only include the Apollo data state
56- data : state . data
53+ data : apollo . cache . extract ( )
5754 }
5855 }
5956 }
@@ -66,7 +63,7 @@ export default ComposedComponent => {
6663
6764 constructor ( props ) {
6865 super ( props )
69- this . apollo = initApollo ( this . props . serverState )
66+ this . apollo = initApollo ( this . props . serverState . apollo . data )
7067 }
7168
7269 render ( ) {
Original file line number Diff line number Diff line change 77 "start" : " next start"
88 },
99 "dependencies" : {
10- "graphql" : " ^0.9.3" ,
10+ "apollo-client-preset" : " ^1.0.1" ,
11+ "graphql" : " ^0.11.7" ,
12+ "graphql-anywhere" : " ^3.1.0" ,
13+ "graphql-tag" : " ^2.5.0" ,
1114 "isomorphic-fetch" : " ^2.2.1" ,
1215 "next" : " latest" ,
1316 "prop-types" : " ^15.5.8" ,
14- "react" : " ^15.5.4 " ,
15- "react-dom " : " ^15.5.4 " ,
16- "react-apollo " : " ^1.1.3 "
17+ "react" : " ^16.0.0 " ,
18+ "react-apollo " : " ^2.0.0 " ,
19+ "react-dom " : " ^16.0.0 "
1720 },
1821 "author" : " " ,
1922 "license" : " ISC"
You can’t perform that action at this time.
0 commit comments