npm package: @r26d/absinthe-apollo-upload-middleware
Description: A network interface for Apollo that enables file-uploading to Absinthe back ends reduced to just middleware to make it easier to work with.
Latest version: 1.1.0

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [@r26d/absinthe-apollo-upload-middleware](#r26dabsinthe-apollo-upload-middleware)
  - [Usage](#usage)
- [This branch is for Apollo V3](#this-branch-is-for-apollo-v3)
    - [Usage with React Native](#usage-with-react-native)
  - [License](#license)
  - [Acknowledgements](#acknowledgements)
  - [API](#api)
    - [ReactNativeFileObject](#reactnativefileobject)
      - [Properties](#properties)
    - [ReactNativeFile](#reactnativefile)
      - [Parameters](#parameters)
    - [](#)
      - [Parameters](#parameters-1)
      - [Examples](#examples)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# @r26d/absinthe-apollo-upload-middleware

> A network interface for Apollo that enables file-uploading to Absinthe back ends reduced to just middleware to make it easier to work with.

## Usage

# This branch is for Apollo V3

I simplified this to just be the middleware. That allows you to use other
middleware to handle the other issues related to the request.

```js
import ApolloClient from 'apollo-client'
import { createHttpLink } from 'apollo-link-http'
import { createUploadMiddleware } from 'apollo-absinthe-upload-link'
import { ApolloLink } from 'apollo-link'

const client = new ApolloClient({
link: ApolloLink.from([
createUploadMiddleware,
createHttpLink({
uri: 'localhost:4000/graphqql',
credentials: 'include'
})
])
})
```

### Usage with React Native

Substitute [`File`](https://developer.mozilla.org/en/docs/Web/API/File) with [`ReactNativeFile`](https://github.com/bytewitchcraft/apollo-absinthe-upload-link/blob/master/src/validators.js):

```js
import { ReactNativeFile } from 'apollo-absinthe-upload-link'

const file = new ReactNativeFile({
uri: '…',
type: 'image/jpeg',
name: 'photo.jpg'
})

const files = ReactNativeFile.list([
{
uri: '…',
type: 'image/jpeg',
name: 'photo-1.jpg'
},
{
uri: '…',
type: 'image/jpeg',
name: 'photo-2.jpg'
}
])
```

## License

[MIT](LICENSE.txt) :copyright:  r26D LLC

## Acknowledgements

*   @labtwentyfive's [`apollo-absinthe-upload-client`](https://github.com/labtwentyfive/apollo-absinthe-upload-client)
*   @jaydenseric [`apollo-upload-client`](https://github.com/jaydenseric/apollo-upload-client)

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### ReactNativeFileObject

*   **See**: <https://github.com/facebook/react-native/blob/v0.45.1/Libraries/Network/FormData.js#L34>

A React Native FormData file object.

Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

#### Properties

*   `uri` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** File system path.
*   `type` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File content type.
*   `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File name.

### ReactNativeFile

A React Native file.

#### Parameters

*   `file` **[ReactNativeFileObject](#reactnativefileobject)** 

    *   `file.uri`  
    *   `file.type`  
    *   `file.name`  

###

Creates an array of file instances.

#### Parameters

*   `files` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[ReactNativeFileObject](#reactnativefileobject)>** 

#### Examples

```javascript
const files = ReactNativeFile.list([{
  uri: uriFromCameraRoll1,
  type: 'image/jpeg',
  name: 'photo-1.jpg'
}, {
  uri: uriFromCameraRoll2,
  type: 'image/jpeg',
  name: 'photo-2.jpg'
}])
```