A network interface for Apollo that enables file-uploading to Absinthe back ends reduced to just middleware to make it easier to work with.
npm install @r26d/absinthe-apollo-upload-middleware
Table of Contents generated with DocToc
- @r26d/absinthe-apollo-upload-middleware
- Usage
- This branch is for Apollo V3
- Usage with React Native
- License
- Acknowledgements
- API
- ReactNativeFileObject
- Properties
- ReactNativeFile
- Parameters
- [](#)
- Parameters
- Examples
> A network interface for Apollo that enables file-uploading to Absinthe back ends reduced to just middleware to make it easier to work with.
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'
})
])
})
`
Substitute File with ReactNativeFile:
`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'
}
])
`
MIT :copyright: r26D LLC
* @labtwentyfive's apollo-absinthe-upload-client
* @jaydenseric apollo-upload-client
* See:
A React Native FormData file object.
Type: Object
#### Properties
* uri String File system path.type
* String? File content type.name
* String? File name.
A React Native file.
#### Parameters
* file ReactNativeFileObject
* file.uri file.type
* file.name
*
###
Creates an array of file instances.
#### Parameters
* files Array<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'
}])