Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
chore: release 0.13.0 (#319)
Browse files Browse the repository at this point in the history
* doc: add release notes for 0.13.0

* doc: add 0.13.0 to website

* chore: release 0.13.0
  • Loading branch information
darahayes authored Jan 9, 2020
1 parent 3a69a75 commit 7197446
Show file tree
Hide file tree
Showing 18 changed files with 904 additions and 24 deletions.
34 changes: 34 additions & 0 deletions docs/ref-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,40 @@ title: What is new in Offix
sidebar_label: Release notes
---

# 0.13.0

The 0.13.0 release is a release contains a couple of bug fixes, dependency updates and the new ability to configure your own `CachePersistor` object as requested in [#273](https://github.com/aerogear/offix/issues/273) and [#281](https://github.com/aerogear/offix/issues/281).

The [CachePersistor](https://github.com/apollographql/apollo-cache-persist#using-cachepersistor) is used by the client to persist the Apollo Cache across application restarts. Pass your own instance to override the one that is created by default.

Example:

```js
import { ApolloOfflineClient, createDefaultCacheStorage } from "offix-client";
import { HttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import { CachePersistor } from "apollo-cache-persist";

const link = new HttpLink({ uri: "http://example.com/graphql" });
const cache = new InMemoryCache()

const cachePersistor = new CachePersistor({
cache,
storage: createDefaultCacheStorage()
})

const client = new ApolloOfflineClient({
cache,
cachePersistor,
link
});
```

Note: if using TypeScript, you may need to declare the cachePersistor as follows `const cachePersistor = new CachePersistor<object>(...options)` or you may experience compiler errors.

This example uses `createDefaultCacheStorage` to create the default IndexedDB based storage driver.
The storage can be swapped depending on the platform. For example `window.localstorage` in older browsers or `AsyncStorage` in [React Native](https://offix.dev/docs/react-native).

# 0.12.0

The 0.12.0 release brings a new `offix-client-boost` package. This package is a batteries-included wrapper around the `offix-client` that brings
Expand Down
4 changes: 2 additions & 2 deletions examples/conflicts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "conflict-examples",
"version": "0.12.0",
"version": "0.13.0",
"private": true,
"description": "",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"express": "^4.16.4",
"graphql": "0.13.2",
"graphql-tools": "^4.0.3",
"offix-conflicts-server": "0.12.0"
"offix-conflicts-server": "0.13.0"
},
"devDependencies": {
"@types/graphql": "^14.0.3",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"examples/*",
"packages/*"
],
"version": "0.12.0",
"version": "0.13.0",
"command": {
"publish": {
"exact": true
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-cache",
"version": "0.12.0",
"version": "0.13.0",
"description": "GraphQL Mutation and Subscription Helpers",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/offix-client-boost/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-client-boost",
"version": "0.12.0",
"version": "0.13.0",
"description": "simplifies setup and usage of offix-client",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand All @@ -23,8 +23,8 @@
"apollo-link-retry": "2.2.15",
"apollo-link-ws": "1.0.19",
"apollo-upload-client": "12.1.0",
"offix-client": "0.12.0",
"offix-conflicts-client": "0.12.0",
"offix-client": "0.13.0",
"offix-conflicts-client": "0.13.0",
"subscriptions-transport-ws": "0.9.16"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/offix-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-client",
"version": "0.12.0",
"version": "0.13.0",
"description": "Offix GraphQL Offline Client",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -48,10 +48,10 @@
"apollo-link-retry": "2.2.15",
"debug": "4.1.1",
"idb-localstorage": "0.2.0",
"offix-cache": "0.12.0",
"offix-conflicts-client": "0.12.0",
"offix-offline": "0.12.0",
"offix-scheduler": "0.12.0"
"offix-cache": "0.13.0",
"offix-conflicts-client": "0.13.0",
"offix-offline": "0.13.0",
"offix-scheduler": "0.13.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-conflicts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-conflicts-client",
"version": "0.12.0",
"version": "0.13.0",
"description": "adds client side conflict detection and resolution",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-conflicts-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-conflicts-server",
"version": "0.12.0",
"version": "0.13.0",
"description": "Offix GraphQL server",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/offix-offline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-offline",
"version": "0.12.0",
"version": "0.13.0",
"description": "Offix package that exposes network interfaces",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/offix-scheduler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-scheduler",
"version": "0.12.0",
"version": "0.13.0",
"description": "",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -33,8 +33,8 @@
},
"dependencies": {
"idb-localstorage": "0.2.0",
"offix-cache": "0.12.0",
"offix-offline": "0.12.0"
"offix-cache": "0.13.0",
"offix-offline": "0.13.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-offix-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-offix-hooks",
"version": "0.12.0",
"version": "0.13.0",
"description": "Use offix-client in react hooks",
"keywords": [
"offix",
Expand Down Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@types/lodash": "4.14.149",
"lodash": "4.17.15",
"offix-client": "0.12.0"
"offix-client": "0.13.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0",
Expand Down
48 changes: 44 additions & 4 deletions website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"title": "Android",
"sidebar_label": "Android"
},
"angular": {
"title": "Angular",
"sidebar_label": "Angular"
},
"getting-started": {
"title": "Getting Started",
"sidebar_label": "Getting Started"
Expand All @@ -24,8 +28,9 @@
"README": {
"title": "README"
},
"ref-advanced": {
"title": "ref-advanced"
"cookbooks": {
"title": "Cookbooks",
"sidebar_label": "Offline Cookbook"
},
"offix-cache": {
"title": "Offix Cache",
Expand Down Expand Up @@ -63,6 +68,9 @@
"title": "Support",
"sidebar_label": "Support"
},
"roadmap": {
"title": "roadmap"
},
"version-0.10.0/version-0.10.0-offix-scheduler-introduction": {
"title": "Offix Scheduler Introduction",
"sidebar_label": "Introduction"
Expand Down Expand Up @@ -95,6 +103,38 @@
"title": "What is new in Offix",
"sidebar_label": "Release notes"
},
"version-0.12.0/version-0.12.0-android": {
"title": "Android",
"sidebar_label": "Android"
},
"version-0.12.0/version-0.12.0-angular": {
"title": "Angular",
"sidebar_label": "Angular"
},
"version-0.12.0/version-0.12.0-getting-started": {
"title": "Getting Started",
"sidebar_label": "Getting Started"
},
"version-0.12.0/version-0.12.0-cookbooks": {
"title": "Cookbooks",
"sidebar_label": "Offline Cookbook"
},
"version-0.12.0/version-0.12.0-offix-cache": {
"title": "Offix Cache",
"sidebar_label": "Client Cache"
},
"version-0.12.0/version-0.12.0-client-configuration": {
"title": "Client Configuration",
"sidebar_label": "Client Configuration"
},
"version-0.12.0/version-0.12.0-offline-client": {
"title": "Offline Support",
"sidebar_label": "Offline Client"
},
"version-0.12.0/version-0.12.0-release-notes": {
"title": "What is new in Offix",
"sidebar_label": "Release notes"
},
"version-0.8.2/version-0.8.2-getting-started": {
"title": "Getting Started",
"sidebar_label": "Getting Started"
Expand Down Expand Up @@ -146,11 +186,11 @@
},
"categories": {
"Getting Started": "Getting Started",
"OffixClient": "OffixClient",
"Offix Client": "Offix Client",
"Platforms": "Platforms",
"Advanced topics": "Advanced topics",
"Releases": "Releases",
"Offix Client": "Offix Client",
"OffixClient": "OffixClient",
"Offix Scheduler": "Offix Scheduler"
}
},
Expand Down
72 changes: 72 additions & 0 deletions website/versioned_docs/version-0.13.0/react-native.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
id: version-0.13.0-react-native
title: React Native
sidebar_label: React Native
original_id: react-native
---

To integrate offix in React Native, developers need to provide custom storage and network layers.

We recomend developers use following React Native plugins:

- `@react-native-community/async-storage` - for storage
- `@react-native-community/netinfo` - for network information

Note: if you are using [Expo](https://expo.io/), you must use the [AsyncStorage included in `react-native`](https://facebook.github.io/react-native/docs/asyncstorage) instead.

## Integration

To integrate with offix we need to create wrappers for storage and network.

Note: if using expo, you will need to `import { AsyncStorage } from 'react-native';` instead of using the `@react-native-community/async-storage` package.

```js
import { ApolloOfflineClient } from 'offix-client'
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
import AsyncStorage from '@react-native-community/async-storage'
import NetInfo from '@react-native-community/netinfo'

// Create cache wrapper
const cacheStorage = {
getItem: async (key) => {
const data = await AsyncStorage.getItem(key);
if (typeof data === 'string') {
return JSON.parse(data);
}
return data;
},
setItem: async (key, value) => {
let valueStr = value;
if (typeof valueStr === 'object') {
valueStr = JSON.stringify(value);
}
return AsyncStorage.setItem(key, valueStr);
}
};

// Create network interface
const networkStatus = {
onStatusChangeListener(callback) {
const listener = (connected) => {
callback.onStatusChange({ online: connected })
};
NetInfo.isConnected.addEventListener('connectionChange', listener)
},
isOffline() {
return NetInfo.isConnected.fetch().then(connected => !connected)
}
};

// Create client
const offlineClient = new ApolloOfflineClient({
cache: new InMemoryCache(),
link: new HttpLink({ uri: 'http://localhost:4000/graphql' }),
offlineStorage: cacheStorage,
cacheStorage,
networkStatus
});
```

For a fully functional example please check react native example app:
https://github.com/aerogear/offix-react-native-example
Loading

0 comments on commit 7197446

Please sign in to comment.