Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}`;
}
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
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}`;
}