Created
February 28, 2018 23:33
-
-
Save andrewdelprete/9eea9e988aad0cc9853437dbc5b106ab to your computer and use it in GitHub Desktop.
Zero config Apollo + GraphQL with apollo-boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "react-dom"; | |
import ApolloClient from "apollo-boost"; | |
import { ApolloProvider } from "react-apollo"; | |
import IpCountryFinder from "./containers/IpCountryFinder"; | |
const client = new ApolloClient({ | |
uri: "https://api.graphloc.com/graphql", | |
clientState: { | |
defaults: { | |
storedIp: "72.229.28.185" | |
}, | |
resolvers: { | |
Mutation: { | |
updateIp: (_, { value }, { cache }) => { | |
cache.writeData({ data: { storedIp: value } }); | |
return null; | |
} | |
} | |
} | |
} | |
}); | |
const ApolloApp = () => ( | |
<ApolloProvider client={client}> | |
<IpCountryFinder ip={window.user_ip} /> | |
</ApolloProvider> | |
); | |
render(<ApolloApp />, document.getElementById("root")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment