Skip to content

Instantly share code, notes, and snippets.

@bstro
Last active March 6, 2018 18:45
Show Gist options
  • Select an option

  • Save bstro/a2108f143fd2a77bf62b27b1a7451804 to your computer and use it in GitHub Desktop.

Select an option

Save bstro/a2108f143fd2a77bf62b27b1a7451804 to your computer and use it in GitHub Desktop.
open ApolloLinks;
open ApolloInMemoryCache;
type dataObject = {
.
"__typename": string,
"id": string,
"key": string
};
/* Create an InMemoryCache */
let inMemoryCache =
createInMemoryCache(~dataIdFromObject=(obj: dataObject) => obj##id, ());
/* Create an HTTP Link */
let httpLink =
ApolloLinks.createHttpLink(~uri="http://localhost:4000/graphql", ());
module Client =
ReasonApollo.CreateClient(
{
let apolloClient =
ReasonApollo.createApolloClient(
~cache=inMemoryCache /* restore method can be piped e.g. inMemoryCache |> restore(window.__APOLLO__) */,
~link=httpLink,
()
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment