Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (hasApollo)
{
var opts = {
credentials: trustNetwork ? "include" : "same-origin",
// transfer request headers to networkInterface so that they're accessible to proxy server
// Addresses this issue: https://github.com/matthew-andrews/isomorphic-fetch/issues/83
headers
}
var networkInterface
if (batchRequests)
{
networkInterface = createBatchingNetworkInterface({
uri: apolloUri,
batchInterval: 10,
opts
})
}
else
{
networkInterface = createNetworkInterface({
uri: apolloUri,
opts
})
}
client = new ApolloClient({
ssrMode,
queryDeduplication,
import DashboardComponent from '../components/Dashboard';
import { SetupDashboard } from '../components/Settings';
import ConfigurationsActions from '../actions/ConfigurationsActions';
import ConfigurationsStore from '../stores/ConfigurationsStore';
import { ApolloClient, ApolloProvider, createNetworkInterface, createBatchingNetworkInterface} from 'react-apollo';
import { makeExecutableSchema } from 'graphql-tools';
interface IDashboardState {
dashboard?: IDashboardConfig;
connections?: IConnections;
connectionsMissing?: boolean;
}
const batchingNetworkInterface = createBatchingNetworkInterface({
uri: 'http://localhost:4000/apollo',
batchInterval: 10,
opts: {
// Options to pass along to `fetch`
}
});
// const networkInterface = createNetworkInterface({ uri: 'http://localhost:4000/apollo' });
// const client = new ApolloClient({ networkInterface: networkInterface });
const client = new ApolloClient({ networkInterface: batchingNetworkInterface });
export default class Dashboard extends React.Component {
state: IDashboardState = {
dashboard: null,
connections: {},
import React, { Component } from 'react'
import {
ApolloProvider,
ApolloClient,
createBatchingNetworkInterface,
} from 'react-apollo'
import { BrowserRouter as Router, Route, Switch, Link } from 'react-router-dom'
import CreateView from './views/CreateView'
import DetailView from './views/DetailView'
import ListView from './views/ListView'
import LoginView from './views/LoginView'
import LogoutView from './views/LogoutView'
const networkInterface = createBatchingNetworkInterface({
uri: 'http://localhost:8000/gql',
batchInterval: 10,
opts: {
credentials: 'same-origin',
},
})
networkInterface.use([
{
applyBatchMiddleware(req, next) {
if (!req.options.headers) {
req.options.headers = {}
}
const token = localStorage.getItem('token')
? localStorage.getItem('token')
function getApolloClient(config) {
const { apiServer, subApiServer } = config.getProperties();
const API_URL = `${apiServer.protocol}//${apiServer.hostname}${apiServer.port ? `:${apiServer.port}` : ''}${apiServer.pathname}`;
const networkInterface = createBatchingNetworkInterface({
uri: `${API_URL}/graphql`,
batchInterval: 10,
});
const SUB_URL = `${subApiServer.protocol}//${subApiServer.hostname}${subApiServer.port ? `:${subApiServer.port}` : ''}${subApiServer.pathname}`;
const wsClient = new SubscriptionClient(`${SUB_URL}/subscriptions`, { reconnect: true });
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient
);
const client = new ApolloClient({
networkInterface: networkInterfaceWithSubscriptions,
queryTransformer: addTypeName,
dataIdFromObject: o => o.id,
});
import { ApolloClient, createBatchingNetworkInterface } from "react-apollo";
const networkInterface = createBatchingNetworkInterface({
uri: "/graphql",
batchInterval: 10,
opts: {
credentials: "same-origin"
}
});
export const graphqlClient = new ApolloClient({
networkInterface: networkInterface
});
import React, { Component } from 'react'
import {
ApolloClient,
ApolloProvider,
createBatchingNetworkInterface,
} from 'react-apollo'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import HomeView from './views/HomeView'
import CreateView from './views/CreateView'
import DetailView from './views/DetailView'
const networkInterface = createBatchingNetworkInterface({
uri: 'http://0.0.0.0:8000/gql/',
batchInterval: 10,
opts: {
credentials: 'same-origin',
},
})
const client = new ApolloClient({
networkInterface: networkInterface,
})
class App extends Component {
render() {
return (