title: Graphql server + NodeJS, store data in cache with Redis
body: <p>I'd like to know how I can improve the response time from connecting graphql to api. I have decided to use Redis. I don't know how exactly should I do it.  </p>
  
  <p>I have built my graphql server:  </p>
  
  <pre><code>import express from 'express';
  import {
      graphqlExpress,
      graphiqlExpress,
  } from 'graphql-server-express';
  import bodyParser from 'body-parser';
  
  import { schema } from './src/schema';
  import cors from 'cors';
  
  import redis from 'redis';
  
  const PORT = 4000;
  const server = express();
  
  const client = redis.createClient();
  
  client.on('error', function (err) {
      console.log('error' + err)
  });
  
  server.use('*', cors({ origin: 'http://localhost:3000' }));
  
  server.use('/graphql', bodyParser.json(), graphqlExpress({
      schema, context: { client }
  }));
  
  
  server.use('/graphiql', graphiqlExpress({
      endpointURL: '/graphql'
  }));
  
  
  
  server.listen(PORT, () =&gt;
      console.log(`GraphQL Server is now running on http://localhost:${PORT}`)
  );
  </code></pre>
  
  <p>I have already imported redis here. My graphql server is connected to front page by cors, so I can render strings from api. In resolver I'm connecting to api by Node.js (if necessary I'll add it.), and I have some custom resolvers here. The response time from api (also affect rendering on page) is too slow- around 10~15s. </p>