-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.js
More file actions
26 lines (22 loc) · 794 Bytes
/
types.js
File metadata and controls
26 lines (22 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
exports.Type = Type;
function Type(args) {
Object.assign(this, args);
}
Type.prototype = {
resolve: function(obj, field, store) {
// If we have a defined resolver for this field use it.
if (this.resolvers && field in this.resolvers)
return this.resolvers[field](obj, store);
// Otherwise return the scalar field from the object.
return {
type: null,
resolved: obj[field]
};
},
// When a cacheKey changes for an object, it invalidate the object's cache
// and the caches of it's parents all the way up the query result tree.
// By default we use random strings so that no caching takes place.
cacheKey: function(obj, store) {
return '(' + Math.random().toString() + ')';
}
}