Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_createRelayNetworkLayer() {
return new RelayNetworkLayer(
[
// batchMiddleware({
// batchUrl: '/graphql/batch',
// batchTimeout: 20,
// }),
cacheMiddleware({
size: 100,
ttl: 15 * 60 * 1000, // 15 minutes
onInit: cache => (this._cache = cache),
}),
urlMiddleware({
url: this.endpoint,
}),
__DEV__ ? loggerMiddleware() : null,
// __DEV__ ? perfMiddleware() : null,
!__DEV__
import {
RelayNetworkLayer,
loggerMiddleware,
errorMiddleware,
perfMiddleware,
retryMiddleware,
authMiddleware,
} from "react-relay-network-modern";
import { getAccessToken } from "./utils/authentication";
// Create a record source & instantiate store
const source = new RecordSource();
const store = new Store(source);
// Create a network layer from the fetch function
const network = new RelayNetworkLayer([
...(process.env.NODE_ENV !== "production"
? [loggerMiddleware(), errorMiddleware(), perfMiddleware()]
: []),
authMiddleware({
token: getAccessToken,
}),
retryMiddleware({
statusCodes: code => code >= 200 && code < 400,
}),
]);
// Create an environment using this network:
const environment = new Environment({
network,
source,
store,
const loc = window.location;
const isSecure = loc.protocol === 'https:' ? 's' : '';
const subscriptionClient = new SubscriptionClient(
`ws${isSecure}://${loc.host}${APP_BASE_PATH}/graphql`,
{
reconnect: true,
},
);
const subscriptionLink = new WebSocketLink(subscriptionClient);
networkSubscriptions = (operation, variables) => execute(subscriptionLink, {
query: operation.text,
variables,
});
}
const network = new RelayNetworkLayer(
[
urlMiddleware({
url: `${APP_BASE_PATH}/graphql`,
credentials: 'same-origin',
}),
uploadMiddleware(),
],
{ subscribeFn: networkSubscriptions },
);
const store = new Store(new RecordSource());
// Activate the read from store then network
// store.holdGC();
export const environment = new Environment({
network,
store,
import 'regenerator-runtime/runtime'
import { Environment, RecordSource, Store } from 'relay-runtime'
import RelayServerSSR from 'react-relay-network-modern-ssr/lib/server'
// import schema from '../../../../graphql/metaphysics/data/schemaj'
// const relayServerSSR = new RelayServerSSR()
import {
RelayNetworkLayer,
urlMiddleware,
// loggerMiddleware,
// gqlErrorsMiddleware,
// perfMiddleware,
} from 'react-relay-network-modern'
const network = new RelayNetworkLayer([
urlMiddleware({ url: process.env.METAPHYSICS_BASE_URL }),
// relayServerSSR.getMiddleware({
// schema,
// contextValue: {},
// }),
// loggerMiddleware(),
// gqlErrorsMiddleware({
// disableServerMiddlewareTip: true,
// }),
// perfMiddleware(),
])
let environment
export function getRelayEnvironment(records) {
if (environment) {
export function createRelayEnvironment(cache) {
const isServer = typeof window === 'undefined'
const relaySSRMiddleware = isServer
? new RelayServerSSR()
: new RelayClientSSR(cache)
relaySSRMiddleware.debug = false
const network = new RelayNetworkLayer([
relaySSRMiddleware.getMiddleware(),
// loggerMiddleware(),
urlMiddleware({
url: process.env.GRAPHQL_ENDPOINT,
}),
])
const source = new RecordSource()
const store = new Store(source)
const environment = new Environment({
network,
store,
})
environment.relaySSRMiddleware = relaySSRMiddleware
return environment
export default function createRelayEnvironment(relaySsr, url) {
return new Environment({
network: new RelayNetworkLayer([
relaySsr.getMiddleware(),
urlMiddleware({ url }),
]),
store: new Store(new RecordSource()),
});
}
type: AlertTypes.error,
});
this.props.saveCurrentPath(PathRedirectKeysMapper.showSuccess);
this.props.invalidateUser();
navigateToModal(this.props.history, '/accountManagement/login');
}
}
}
}
return response;
},
];
const network = new RelayNetworkLayer(middlewaresArray);
return network;
};