@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
uristring Filesystem path.namestring? File name.typestring? File content type. Some environments (particularly Android) require a valid MIME type; ExpoImageResult.typeis 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
fileReactNativeFileSubstitute A React NativeFilesubstitute.
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
optionsobject Options.options.uristring GraphQL endpoint URI. (optional, default/graphql)options.fetchFunction?fetchimplementation to use, defaulting to thefetchglobal.options.fetchOptionsFetchOptions?fetchoptions; overridden by upload requirements.options.credentialsstring? Overridesoptions.fetchOptions.credentials.options.headersobject? Merges with and overridesoptions.fetchOptions.headers.options.includeExtensionsboolean Toggles sendingextensionsfields 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