Replacing apollo-fetch-upload for the new Apollo Client v2 compatible apollo-upload-client.

Also updated dependencies.
This commit is contained in:
Jayden Seric 2017-11-08 14:47:50 +11:00
parent 1799440d65
commit 413e4f80fa
3 changed files with 765 additions and 769 deletions

View File

@ -1,9 +1,9 @@
import 'isomorphic-unfetch'
import { Component } from 'react' import { Component } from 'react'
import { ApolloClient } from 'apollo-client' import { ApolloClient } from 'apollo-client'
import BatchHttpLink from 'apollo-link-batch-http' import { InMemoryCache } from 'apollo-cache-inmemory'
import InMemoryCache from 'apollo-cache-inmemory' import { createUploadLink } from 'apollo-upload-client'
import { getDataFromTree, ApolloProvider } from 'react-apollo' import { getDataFromTree, ApolloProvider } from 'react-apollo'
import { createApolloFetchUpload } from 'apollo-fetch-upload'
import getDisplayName from 'react-display-name' import getDisplayName from 'react-display-name'
import Head from 'next/head' import Head from 'next/head'
@ -17,16 +17,13 @@ let apolloClient
* @param {Object} [initialState] - Redux initial state. * @param {Object} [initialState] - Redux initial state.
* @returns {Object} Apollo Client instance. * @returns {Object} Apollo Client instance.
*/ */
const createApolloClient = (initialState = {}) => { const createApolloClient = (initialState = {}) =>
const link = new BatchHttpLink({ new ApolloClient({
fetch: createApolloFetchUpload({ uri: process.env.API_URI }) ssrMode,
cache: new InMemoryCache().restore(initialState),
link: createUploadLink({ uri: process.env.API_URI })
}) })
const cache = new InMemoryCache().restore(initialState)
return new ApolloClient({ link, cache, ssrMode })
}
export default ComposedComponent => export default ComposedComponent =>
class WithData extends Component { class WithData extends Component {
static displayName = `WithData(${getDisplayName(ComposedComponent)})` static displayName = `WithData(${getDisplayName(ComposedComponent)})`

1487
app/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,30 +6,30 @@
"npm": ">=5.4" "npm": ">=5.4"
}, },
"dependencies": { "dependencies": {
"apollo-cache-inmemory": "^0.2.0-beta.4", "apollo-cache-inmemory": "^1.1.0",
"apollo-client": "^2.0.0-beta.4", "apollo-client": "^2.0.2",
"apollo-fetch-upload": "^1.1.0", "apollo-link": "^1.0.0",
"apollo-link": "^0.7.0", "apollo-upload-client": "^6.0.0-beta.1",
"apollo-link-batch-http": "^0.3.0",
"babel-plugin-transform-inline-environment-variables": "^0.2.0", "babel-plugin-transform-inline-environment-variables": "^0.2.0",
"dotenv-cli": "^1.4.0", "dotenv-cli": "^1.4.0",
"graphql": "^0.10.5", "graphql": "^0.11.7",
"graphql-tag": "^2.4.2", "graphql-tag": "^2.5.0",
"next": "^4.0.0-beta.2", "isomorphic-unfetch": "^2.0.0",
"next": "^4.1.4",
"react": "^16.0.0", "react": "^16.0.0",
"react-apollo": "^2.0.0-beta.0", "react-apollo": "^2.0.0",
"react-display-name": "^0.2.3", "react-display-name": "^0.2.3",
"react-dom": "^16.0.0", "react-dom": "^16.0.0",
"webpack-bundle-analyzer": "^2.9.0" "webpack-bundle-analyzer": "^2.9.0"
}, },
"devDependencies": { "devDependencies": {
"babel-eslint": "^8.0.1", "babel-eslint": "^8.0.2",
"eslint": "^4.8.0", "eslint": "^4.10.0",
"eslint-plugin-import": "^2.7.0", "eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.0", "eslint-plugin-node": "^5.2.1",
"eslint-plugin-prettier": "^2.3.1", "eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0", "eslint-plugin-react": "^7.4.0",
"prettier": "^1.7.4" "prettier": "^1.8.1"
}, },
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint .",