Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
// define ApolloClient's NetworkInterface, that will resolve the queries locally
const localGraphQLNetworkInterface = {
query: (graphqlRequest) => graphql(
graphqlSchema,
print(graphqlRequest.query),
null,
null,
graphqlRequest.variables,
graphqlRequest.operationName
)
};
// initialize ApolloClient
const apolloClient = new ApolloClient({
networkInterface: localGraphQLNetworkInterface
});
app.use('/graphql', expressGraphql({
schema: graphqlSchema,
graphiql: true
}));
// Server-Side-Rendering
app.use((req, res) => {
const history = createMemoryHistory(req.path);
const routes = getRoutes();
// Find the correct route
match({ history, routes, location: req.url }, (err, redirectLocation, renderProps) => {
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var axios = require('axios');
var swig = require('swig');
var gql = require('graphql-tag');
var ApolloClient = require('apollo-client').default;
var createNetworkInterface = require('apollo-client').createNetworkInterface;
var networkInterface = createNetworkInterface({ uri: 'https://api.graph.cool/simple/v1/cj4i1ifeamv640130f4nkogb0' });
var client = new ApolloClient({ networkInterface: networkInterface });
require('es6-promise').polyfill();
require('isomorphic-fetch');
app.set('port', (process.env.PORT || 5000))
app.engine('html', swig.renderFile);
app.set('view engine', 'html');
app.set('views', __dirname + '/build');
app.use(bodyParser.json());
app.get(['/', '/scrape/:key'], function(req, res) {
const key = req.params.key;
console.log('KEY', key);
let initialData = {
createClient(options) {
return new ApolloClient(this.enhanceClientOptions(options));
}
createClient: function(options) {
return new ApolloClient(this.enhanceClientOptions(options));
},
enhanceClientOptions: function(options) {
createClient(options) {
return new ApolloClient(this.enhanceClientOptions(options));
}
function getApolloClient({link}) {
return new ApolloClient({
link,
cache: new InMemoryCache(),
})
}
createClient(options) {
return new ApolloClient(this.enhanceClientOptions(options));
}
createClient(options) {
return new ApolloClient(this.enhanceClientOptions(options));
}