Skip to content

pedson/apollo-upload-network-interface

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apollo-upload-network-interface

UploadNetworkInterface for Apollo GraphQL Client. Adds support for multipart/form-data requests.

Used together with graphql-server-express-upload and graphql-server-koa-upload (coming soon).

Any help is appreciated!

Usage

import ApolloClient from 'apollo-client'
import createNetworkInterface from 'apollo-upload-network-interface'

const networkInterface = createNetworkInterface({
  uri: '/graphql',
})

const client = new ApolloClient({
  networkInterface
})

If you get an error like this

/node_modules/apollo-client/transport/networkInterface.js:9
import 'whatwg-fetch';
^^^^^^

SyntaxError: Unexpected token import

You need to configure you babel-loader like this

{
  test: /\.js$/,
  loader: 'babel-loader',
  exclude: /node_modules\/(?!(apollo-client)\/).*/,
  include: [
    path.resolve(__dirname, '..', 'config'),
    path.resolve(__dirname, '..', 'client'),
    path.resolve(__dirname, '..', 'node_modules', 'apollo-client'),
    //reactMdlExtraPath,
  ],
  query: {
    cacheDirectory: true,
  },
}

TODO

  • Add tests
  • Convert to typescript

About

UploadNetworkInterface for Apollo GraphQL Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%