File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,16 @@ const hash = require('object-hash');
22
33const toSafeObject = obj => JSON . parse ( JSON . stringify ( obj || { } ) ) ;
44
5- function cache ( func , options ) {
5+ function cache ( func , options = { } ) {
66 return ( root , args , context ) => {
77 if ( ! context . resolverCache ) {
88 throw new Error ( 'Missing resolverCache property on the Graphql context.' ) ;
99 }
10+
11+ const key = options . key
12+ ? options . key ( root , args , context )
13+ : `${ hash ( func ) } :${ hash ( toSafeObject ( root ) ) } :${ hash ( toSafeObject ( args ) ) } ` ;
1014
11- const key = `${ hash ( func ) } :${ hash ( toSafeObject ( root ) ) } :${ hash ( toSafeObject ( args ) ) } ` ;
1215 const executeAndCache = ( ) =>
1316 Promise . resolve ( func ( root , args , context ) ) . then ( ( value ) => {
1417 context . resolverCache . set ( key , value , options ) ;
You can’t perform that action at this time.
0 commit comments