@r26d/absinthe-apollo-upload-client v0.0.12
Table of Contents generated with DocToc
@r26d/absinthe-apollo-upload-client
A terminating Apollo Link for Apollo Client that allows FileList, File, Blob or ReactNativeFile instances within query or mutation variables and sends GraphQL multipart requests. Modified to support the Absinthe way of posting files
apollo-upload-client-absinthe
This fork modifies the request format to support Absinthe's way of handling file uploads.
API
ReactNativeFileSubstitute
A React Native File
substitute.
Be aware that inspecting network requests with Chrome dev tools interferes
with the React Native FormData
implementation, causing network errors.
Type: object
Properties
uri
string Filesystem path.name
string? File name.type
string? File content type. Some environments (particularly Android) require a valid MIME type; ExpoImageResult.type
is unreliable as it can be justimage
.
Examples
A camera roll file.
```js
{
uri: uriFromCameraRoll,
name: 'a.jpg',
type: 'image/jpeg'
}
```
ReactNativeFile
Used to mark a
React Native File
substitute(#reactnativefilesubstitute).
It’s too risky to assume all objects with uri
, type
and name
properties
are files to extract. Re-exported from extract-files
for convenience.
Parameters
file
ReactNativeFileSubstitute A React NativeFile
substitute.
Examples
A React Native file that can be used in query or mutation variables.
```js
const { ReactNativeFile } = require('apollo-upload-client')
const file = new ReactNativeFile({
uri: uriFromCameraRoll,
name: 'a.jpg',
type: 'image/jpeg'
})
```
FetchOptions
GraphQL request fetch
options.
Type: object
Properties
createUploadLink
- See: GraphQL multipart request spec.
- See: apollo-link on GitHub.
Creates a terminating Apollo Link
capable of file uploads. Options match createHttpLink
.
Parameters
options
object Options.options.uri
string GraphQL endpoint URI. (optional, default/graphql
)options.fetch
Function?fetch
implementation to use, defaulting to thefetch
global.options.fetchOptions
FetchOptions?fetch
options; overridden by upload requirements.options.credentials
string? Overridesoptions.fetchOptions.credentials
.options.headers
object? Merges with and overridesoptions.fetchOptions.headers
.options.includeExtensions
boolean Toggles sendingextensions
fields to the GraphQL server. (optional, defaultfalse
)
Examples
A basic Apollo Client setup.
```js
const { ApolloClient } = require('apollo-client')
const { InMemoryCache } = require('apollo-cache-inmemory')
const { createUploadLink } = require('apollo-upload-client')
const client = new ApolloClient({
cache: new InMemoryCache(),
link: createUploadLink()
})
```
Returns ApolloLink A terminating Apollo Link capable of file uploads.
API
License
MIT :copyright: r26D LLC