Skip to content

Instantly share code, notes, and snippets.

@andrewdelprete
Created February 28, 2018 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewdelprete/9eea9e988aad0cc9853437dbc5b106ab to your computer and use it in GitHub Desktop.
Save andrewdelprete/9eea9e988aad0cc9853437dbc5b106ab to your computer and use it in GitHub Desktop.
Zero config Apollo + GraphQL with apollo-boost
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