Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Caching for Graphql Resolvers

License

NotificationsYou must be signed in to change notification settings

Intellicode/graphql-resolver-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Greenkeeper badge

Maintenance StatusNPM versionBuild StatusDependency StatusCoverage StatusCode ClimateBCH compliance

Easy wrapper around resolvers to cache results based on root elements and Graphql query arguments. Works best with Apollo Graphql.

Installation

$ npm install graphql-resolver-cache --save

Configuration

Add a cache to your Graphql middleware:

importexpressfrom'express';importbodyParserfrom'body-parser';import{graphqlExpress}from'apollo-server-express';import{LruCache}from'graphql-resolver-cache';constmyGraphQLSchema=// ... define or import your schema here!constPORT=3000;constapp=express();constresolverCache=newLruCache();// bodyParser is needed just for POST.app.use('/graphql',bodyParser.json(),graphqlExpress({schema:myGraphQLSchema,context:{ resolverCache}}));app.listen(PORT);

Wrap your resolver in a cache function:

import{withCache}from'graphql-resolver-cache';exportdefault{User:{getFriends:withCache((root,args,context)=>{/* logic */}),},};

About

Caching for Graphql Resolvers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp