Last active
March 6, 2018 18:45
-
-
Save bstro/a2108f143fd2a77bf62b27b1a7451804 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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