Offix can be used with existing Apollo GraphQL applications as an extension to the Apollo Client. The Offix Client provides additional methods that support various offline use cases.
Installing Offix Client
Using the Client inside your application
To work with Offix you should create Offix client.
NOTE: Offix client extends Apollo Client - if you already using Apollo Client you would need to swap it with the Offix client implementation
ApolloOfflineClient is a full
ApolloClient but with some additional features for building offline workflows.
client.init must be resolved before the application makes any queries/mutations, otherwise the cache and storage mechanisms may not work properly.
Offix Client Boost
offix-client-boost is a convenient way to create a client already bundled with all you nead to work with GraphQL.
Mainly an cache and Apollo Links subscriptions and file uploads.
Offix Boost is recomended if you trying to build your first GraphQL application and want to have seamless experience.
Working with client
Client will offer the same API as Apollo GraphQL client. Offix will supply additional methods that help with offline experience.
The following example shows the
client.offlineMutate() method which support sending new mutation while the application is considered offline.
When offline, an error is returned with a reference to a promise which can be used to wait for the mutation to complete. This will happen when the application comes back online.
async/await can be used too.
Non Offline realated API
ApolloOfflineClient is and extension of the Apollo GraphQL client and can be used with various web and mobile frameworks.
For basic concepts about Apollo GraphQL please refer to the documentation for your own platform.
For React: https://www.apollographql.com/docs/react/
For Angular: https://www.apollographql.com/docs/angular/