How to use the apollo-upload-client.createBatchingNetworkInterface function in apollo-upload-client

To help you get started, we’ve selected a few apollo-upload-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strues / boldr / src / core / entry / client.js View on Github external
import App from '../App';

// Async font loading
WebFontLoader.load({
  google: {
    families: ['Roboto:300,600', 'Chivo:400,600'],
  },
});

const MOUNT_POINT = document.getElementById('app');
// Load the JWT if it exists.
// Get token will return null if it does not exist
const token = getToken();

// Apollo network interface
const networkInterface = createBatchingNetworkInterface({
  uri: process.env.BOLDR_GRAPHQL_URL,
  batchInterval: 10,
});
networkInterface.use([
  {
    applyBatchMiddleware(req, next) {
      // If headers don't exist for some reason
      // create them.
      if (!req.options.headers) {
        req.options.headers = {};
      }

      // Add our auth token to the headers
      // Authorization: 'Bearer Token'
      if (token) {
        req.options.headers.authorization = `Bearer ${token}`;
github strues / boldr / src / core / createApolloClient.js View on Github external
}
    params.ssrForceFetchDelay = 100;
    params.connectToDevTools = true;
  } else {
    params.ssrMode = true;
  }

  return new ApolloClient(params);
};

// Load the JWT if it exists.
// Get token will return null if it does not exist
const token = getToken();

// Apollo network interface
const networkInterface = createBatchingNetworkInterface({
  uri: process.env.GRAPHQL_ENDPOINT,
  batchInterval: 10,
});

networkInterface.use([
  {
    applyBatchMiddleware(req, next) {
      // If headers don't exist for some reason create them.
      if (!req.options.headers) {
        req.options.headers = {};
      }
      if (!process.browser) {
        req.options.headers.credentials = 'same-origin';
        req.options.headers.credentials = req.headers;
      }
      // Add our auth token to the headers
github srtucker22 / chatty / client / src / app.js View on Github external
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
import { persistStore, autoRehydrate } from 'redux-persist';
import thunk from 'redux-thunk';
import _ from 'lodash';
import { WillPresentNotificationResult } from 'react-native-fcm';
import { NavigationActions } from 'react-navigation';
import { createBatchingNetworkInterface } from 'apollo-upload-client';

import AppWithNavigationState, { navigationReducer } from './navigation';
import auth from './reducers/auth.reducer';
import { logout } from './actions/auth.actions';
import { FirebaseClient } from './firebase-client';

const URL = 'localhost:8080'; // set your comp's url here

const networkInterface = createBatchingNetworkInterface({
  uri: `http://${URL}/graphql`,
  batchInterval: 10,
  queryDeduplication: true,
});

// middleware for requests
networkInterface.use([{
  applyBatchMiddleware(req, next) {
    if (!req.options.headers) {
      req.options.headers = {};
    }
    // get the authentication token from local storage if it exists
    const jwt = store.getState().auth.jwt;
    if (jwt) {
      req.options.headers.authorization = `Bearer ${jwt}`;
    }

apollo-upload-client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis