Setting Up Apollo
Dependencies
In order to use Apollo with the generated code, you'll need to install:
- The bindings package,
reason-react-apollo
(included in this project) - Future, as
reason-future
, a third-party library that includes the Promise-compatible types these bindings use (read more about this here) - Apollo's hooks library,
@apollo/react-hooks
yarn add reason-react-apollo reason-future @apollo/react-hooks
And then update your bsconfig.json
:
"bs-dependencies": [
"reason-react-apollo",
"reason-future"
]
Creating Your Apollo Client
The bindings include the ability to create an instance of an Apollo client using the apollo-boost library.
let client = Apollo.createClient(~uri="/graphql", ());
[@react.component]
let make = () => {
<Apollo.Provider client>
<App/>
</Apollo.Provider>
}
For a full list of the available options you can use when creating your client, check out Apollo's docs.
Eventually this project will probably support more of the underlying API for creating a client. If that's important to you, feel free to file an issue!