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.12.0 (#289)
Browse files Browse the repository at this point in the history
* chore: release 0.12.0

* doc: 0.12.0 version on website
  • Loading branch information
darahayes authored Dec 5, 2019
1 parent e39a45d commit 7ffb9e1
Show file tree
Hide file tree
Showing 21 changed files with 983 additions and 20 deletions.
7 changes: 7 additions & 0 deletions docs/ref-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ title: What is new in Offix
sidebar_label: Release notes
---

# 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
everything needed to get started with GraphQL quickly. This includes a cache and support for subscriptions and file uploads.

Check out the new documentation at [offix.dev](https://offix.dev).

# 0.11.0

The 0.11.0 release simplifies the creation of offline clients.
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.11.0",
"version": "0.12.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.11.0"
"offix-conflicts-server": "0.12.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.11.0",
"version": "0.12.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.11.0",
"version": "0.12.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.11.0",
"version": "0.12.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.11.0",
"offix-conflicts-client": "0.11.0",
"offix-client": "0.12.0",
"offix-conflicts-client": "0.12.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.11.0",
"version": "0.12.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.11.0",
"offix-conflicts-client": "0.11.0",
"offix-offline": "0.11.0",
"offix-scheduler": "0.11.0"
"offix-cache": "0.12.0",
"offix-conflicts-client": "0.12.0",
"offix-offline": "0.12.0",
"offix-scheduler": "0.12.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.11.0",
"version": "0.12.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.11.0",
"version": "0.12.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.11.0",
"version": "0.12.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.11.0",
"version": "0.12.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.11.0",
"offix-offline": "0.11.0"
"offix-cache": "0.12.0",
"offix-offline": "0.12.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.11.0",
"version": "0.12.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.11.0"
"offix-client": "0.12.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0",
Expand Down
14 changes: 14 additions & 0 deletions website/versioned_docs/version-0.12.0/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: version-0.12.0-android
title: Android
sidebar_label: Android
original_id: android
---

Offix supports Android platform by seprate project called Offix Android.

Offix Android Documentation:
http://android.offix.dev

Offix Android Github:
https://github.com/aerogear/offix-android
16 changes: 16 additions & 0 deletions website/versioned_docs/version-0.12.0/angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: version-0.12.0-angular
title: Angular
sidebar_label: Angular
original_id: angular
---

Offix does not provide a specific API for Angular,
However, the regular `offix-client` module can be used for most use cases.

## Example Angular Application

We maintain an Angular based example Ionic application that showcases how to use Offix.
For more information please check:

https://github.com/aerogear/ionic-showcase/
130 changes: 130 additions & 0 deletions website/versioned_docs/version-0.12.0/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
id: version-0.12.0-getting-started
title: Getting Started
sidebar_label: Getting Started
original_id: getting-started
---

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.

Offix supports multiple platforms by extendable javascript library and individual wrappers for
specific web and cross platform frameworks.


## Installing Offix Client

Using [npm](https://www.npmjs.com/package/offix-client):

```shell
npm install offix-client
```

Or [yarn](https://yarnpkg.com/en/package/offix-client):

```shell
yarn add 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

```javascript
import { ApolloOfflineClient } from 'offix-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from "apollo-link-http";

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

// create the client
const client = new ApolloOfflineClient(config);

// initialise the client
// Client needs to be installised before any other queries and mutations will happen.
// Please see platform guide to see how this can be done in React, Angular etc.
await client.init();
```

The `ApolloOfflineClient` is a full `ApolloClient` but with some additional features for building offline workflows.

**Note** `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

The `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](https://www.apollographql.com/docs/link/) subscriptions and file uploads.
Offix Boost is recomended if you trying to build your first GraphQL application and want to have seamless experience.

```js
import { createClient } from 'offix-client-boost'

const config = {
httpUrl: 'http://example.com/graphql',
wsUrl: 'ws://example.com/graphql'
}

const client = await createClient(config)
```

## 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.

```js
const options = {
mutation: gql`
mutation greeting($name: String!){
greeting(name: $name) {
body
}
}`,
variables: {
name: 'hello world!'
}
};

client.offlineMutate(options).catch((error) => {
// we are offline - lets wait for changes
if(error.offline) {
error.watchOfflineChange().then((result) => {
console.log('mutation was completed after we came back online!', result)
})
}
});
```

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.

```js
try {
await client.offlineMutate(options)
} catch(error) {
if(error.offline) {
const result = await error.watchOfflineChange()
console.log('mutation was completed after we came back online!', result)
}
}
```

## 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/
37 changes: 37 additions & 0 deletions website/versioned_docs/version-0.12.0/ref-advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: version-0.12.0-cookbooks
title: Cookbooks
sidebar_label: Offline Cookbook
original_id: cookbooks
---


# Offix Cookbook

This section contains multiple tips and tricks for working with Offix.


## Implementing Custom Network Status checks

To use your own custom network checks, implement the [NetworkStatus](NetworkStatus.ts)
interface which provides two functions;

```javascript
onStatusChangeListener(callback: NetworkStatusChangeCallback): void;

isOffline(): boolean;
```

This interface can be used to redefine what being offline means.
For example, for some use cases developers might decide to use scheduler only when Wifi connection is available.

## Querying Data when Offline

To make sure that data will be available when the devices comes back online, we need to query it with the proper
`fetchPolicy`

We recommend to always use the default fetch policy and to let Offix to control the flow. However, for advanced use cases
developers can modify their approach.

For more information see:
https://medium.com/@wtr/data-query-patterns-for-graphql-clients-af66830531aa
Loading

0 comments on commit 7ffb9e1

Please sign in to comment.