title: How to add redis client for caching in GraphQL resolver
body: <p>Any idea how we can write graphQL resolver so that I can cache API response in the redis and on the next call it takes data from the redis instead of hitting the backend API response ?</p>
  
  <p>Here user name is unique in the API. i.e. 1. getify and 2. bradtraversy</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/// Middleware Function to Check Cache
  checkCache = (username) =&gt; {
    redis.get(username, (err, data) =&gt; {
      if (err) {
        console.log("====111111111111==========");
        console.log(err);
  
      }
      if (data !== null) {
        personInfo = data;
        // console.log(data);
        console.log("============222222222222=========");
        return personInfo;
      } 
    });
  };
  
  // Running Code 
  const resolvers = {
    Query: {
     getPerson: async (_, { username }) =&gt; {
        await checkCache(username);
        console.log(username);
        if(null != personInfo) {
          console.log("=======333333333=======")
          console.log(personInfo);
          return JSON.parse(personInfo);
        }
        else {
          console.log("Fetching Data from API")
          console.log(username);
          const response = await fetch(`https://api.github.com/users/${username}`).then(response =&gt; response.json());
          redis.SETEX(username, 300, JSON.stringify(response)); 
          // console.log(response);
          return response;
        }
      }
      }
  
      </code></pre>
  </div>
  </div>
  </p>