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.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
darahayes authored and wtrocki committed Mar 6, 2020
1 parent a9ee41d commit 2b84485
Show file tree
Hide file tree
Showing 15 changed files with 776 additions and 22 deletions.
8 changes: 4 additions & 4 deletions examples/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offix-react-example",
"version": "0.13.2",
"version": "0.14.0",
"main": "index.js",
"license": "Apache-2.0",
"private": true,
Expand All @@ -19,11 +19,11 @@
"apollo-link-ws": "^1.0.19",
"graphql": "^14.3.1",
"graphql-tag": "^2.10.1",
"offix-cache": "0.13.2",
"offix-client": "0.13.2",
"offix-cache": "0.14.0",
"offix-client": "0.14.0",
"react": "^16.13.0",
"react-dom": "^16.8.0",
"react-offix-hooks": "0.13.2",
"react-offix-hooks": "0.14.0",
"spectre.css": "^0.5.8",
"subscriptions-transport-ws": "^0.9.16"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-runtime-template",
"version": "0.13.2",
"version": "0.14.0",
"description": "",
"private": true,
"license": "Apache 2.0",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.13.2",
"version": "0.14.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.13.2",
"version": "0.14.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.13.2",
"version": "0.14.0",
"description": "simplifies setup and usage of offix-client",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand All @@ -22,8 +22,8 @@
"apollo-link-retry": "2.2.15",
"apollo-link-ws": "1.0.19",
"apollo-upload-client": "12.1.0",
"offix-client": "0.13.2",
"offix-conflicts-client": "0.13.2",
"offix-client": "0.14.0",
"offix-conflicts-client": "0.14.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.13.2",
"version": "0.14.0",
"description": "Offix GraphQL Offline Client",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -46,10 +46,10 @@
"apollo-link-error": "1.1.12",
"apollo-link-http": "1.5.16",
"apollo-link-retry": "2.2.15",
"offix-cache": "0.13.2",
"offix-conflicts-client": "0.13.2",
"offix-offline": "0.13.2",
"offix-scheduler": "0.13.2",
"offix-cache": "0.14.0",
"offix-conflicts-client": "0.14.0",
"offix-offline": "0.14.0",
"offix-scheduler": "0.14.0",
"traverse": "0.6.6"
},
"peerDependencies": {
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.13.2",
"version": "0.14.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.13.2",
"version": "0.14.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.13.2",
"version": "0.14.0",
"description": "Offix package that exposes network interfaces",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
4 changes: 2 additions & 2 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.13.2",
"version": "0.14.0",
"description": "",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down Expand Up @@ -30,7 +30,7 @@
"typescript": "3.7.5"
},
"dependencies": {
"offix-offline": "0.13.2"
"offix-offline": "0.14.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.13.2",
"version": "0.14.0",
"description": "Use offix-client in react hooks",
"keywords": [
"offix",
Expand Down Expand Up @@ -44,7 +44,7 @@
"typescript": "3.7.5"
},
"dependencies": {
"offix-client": "0.13.2"
"offix-client": "0.14.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0",
Expand Down
138 changes: 138 additions & 0 deletions website/versioned_docs/version-0.14.0/ref-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
id: version-0.14.0-client-configuration
title: Client Configuration
sidebar_label: Client Configuration
original_id: client-configuration
---

## offix-client

### `ApolloOfflineClient`

`ApolloOfflineClient` extends the `ApolloClient` class. Check the [`ApolloClient` constructor docs](https://www.apollographql.com/docs/react/v2.5/api/apollo-client/#apolloclient) to see the options that can be passed.

There are some additional options specific to `ApolloOfflineClient`.

#### `networkStatus`

[NetworkStatus](https://github.com/aerogear/offix/blob/master/packages/offix-offline/src/network/NetworkStatus.ts) Interface for detecting changes in network status. (Uses browser networking APIs by default)

#### `offlineStorage`

The [PersistentStore](https://github.com/aerogear/offix/blob/master/packages/offix-scheduler/src/store/PersistentStore.ts) you want your client to use for persisting offline operations in the offline queue (Uses IndexedDB by default).

#### `cacheStorage`

The [PersistentStore](https://github.com/aerogear/offix/blob/master/packages/offix-scheduler/src/store/PersistentStore.ts) you want your client to use for persisting the Apollo Cache (Uses IndexedDB by default).

#### `cachePersistor`

The [CachePersistor](https://github.com/apollographql/apollo-cache-persist#using-cachepersistor) instance 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](./react-native.md).


#### `offlineQueueListener`

[ApolloOfflineQueueListener](./ref-offline.md#listening-for-events) User provided listener that contains a set of methods that are called when certain events occur in the queue.

#### `conflictProvider`

[ObjectState](./ref-conflict-server.md#implementing-custom-conflict-resolution) Interface that defines how object state is progressed. This interface needs to match state provider supplied on server.

#### `conflictStrategy`

[ConflictResolutionStrategy](https://github.com/aerogear/offix/blob/master/packages/offix-conflicts-client/src/strategies/ConflictResolutionStrategy.ts)interface used on the client to resolve conflicts. The [default strategy](https://github.com/aerogear/offix/blob/master/packages/offix-conflicts-client/src/strategies/strategies.ts) merges client changes onto the server changes.

#### `mutationCacheUpdates`

[CacheUpdates](./ref-offline.md#global-update-functions) Cache updates functions for your mutations. Argument allows to restore optimistic responses on application restarts.

#### `retryOptions`

The options to configure how failed offline mutations are retried. See [`apollo-link-retry`](https://www.apollographql.com/docs/link/links/retry/).

#### `inputMapper`

If your mutation variables are not passed directly, for example if you use input types, an `inputMapper` is a set of functions that tells Offix how to read the mutation `variables`.

For example, if your mutations use Input types:

```js
const CREATE_TASK = gql`
mutation createTask($input: TaskInput!) {
createTask(input: $input) {
id
title
description
}
}`

client.offlineMutate({
mutation: CREATE_TASK,
variables: {
input: {
title: 'new task title',
description: 'new task description'
}
},
returnType: 'Task'
})
```

`ApolloOfflineClient` will need an additional `inputMapper` object with the following functions:

* `deserialize` - to know how to convert the `variables` object into a flat object that can be used to generate optimistic responses and cache update functions.
* `serialize` - to know how to convert the serialized object back into the correct `variables` object after performing conflict resolution.

```js
import { ApolloOfflineClient, createDefaultCacheStorage } from "offix-client";

const client = new ApolloOfflineClient({
cache: new InMemoryCache(),
link: new HttpLink({ uri: "http://example.com/graphql" }),
inputMapper: {
deserialize: (variables) => { return variables.input },
serialize: (variables) => { return { input: variables } }
}
});
```

## offix-client-boost

### `createClient`

`createClient` accepts all of the `ApolloOfflineClient` options described above as well as the ones listed below.

* `httpUrl` (required) - The URL of the GraphQL server
* `wsUrl` (required) - The URL of the websocket endpoint for subscriptions
* `cache` - The Apollo [InMemoryCache](https://www.apollographql.com/docs/react/caching/cache-configuration/) that will be used. (creates one by default).
* `authContextProvider` - An object or an `async` function that returns an [`AuthContext`](https://github.com/aerogear/offix/blob/master/packages/offix-client-boost/src/auth/AuthContexrProvider.ts) object with authentication headers that will be passed in GraphQL requests and in the `connectionParams` of websocket connections.
* `fileUpload` - If set to `true`, GraphGL file uploads will be enabled and supported. (default is `false`)
* `websocketClientOptions` - Options for the websocket client used for subscriptions. See [subscriptions-transport-ws](https://www.npmjs.com/package/subscriptions-transport-ws)
Loading

0 comments on commit 2b84485

Please sign in to comment.