Skip to content

r26D/apollo-absinthe-upload-link

 
 

Repository files navigation

Apollo-Absinthe-Upload-Link

A network interface for Apollo that enables file-uploading to Absinthe back ends.

Usage

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

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 with ReactNativeFile:

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 (see LICENSE)

Acknowledgements

About

A network interface for Apollo that enables file-uploading to Absinthe back ends.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%