apollo-cache-control
Advanced tools
Comparing version 0.1.0 to 0.1.1
# Changelog | ||
### v0.1.1 | ||
* Fix `defaultMaxAge` feature (introduced in 0.1.0) so that `maxAge: 0` overrides the default, as previously documented. | ||
### v0.1.0 | ||
@@ -4,0 +8,0 @@ |
@@ -99,2 +99,16 @@ "use strict"; | ||
}); }); | ||
it('should overwrite the default maxAge when maxAge=0 is specified on the type', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var schema, hints; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
schema = graphql_1.buildSchema("\n type Query {\n droid(id: ID!): Droid\n }\n\n type Droid @cacheControl(maxAge: 0) {\n id: ID!\n name: String!\n }\n "); | ||
return [4 /*yield*/, helpers_1.collectCacheControlHints(schema, "\n query {\n droid(id: 2001) {\n name\n }\n }\n ", { defaultMaxAge: 10 })]; | ||
case 1: | ||
hints = _a.sent(); | ||
expect(hints).toContainEqual({ path: ['droid'], maxAge: 0 }); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it('should override the maxAge from the target type with that specified on a field', function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -101,0 +115,0 @@ var schema, hints; |
@@ -109,3 +109,3 @@ "use strict"; | ||
return { | ||
maxAge: otherHint.maxAge || hint.maxAge, | ||
maxAge: otherHint.maxAge !== undefined ? otherHint.maxAge : hint.maxAge, | ||
scope: otherHint.scope || hint.scope | ||
@@ -112,0 +112,0 @@ }; |
{ | ||
"name": "apollo-cache-control", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A GraphQL extension for cache control", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -116,2 +116,29 @@ import { | ||
it('should overwrite the default maxAge when maxAge=0 is specified on the type', async () => { | ||
const schema = buildSchema(` | ||
type Query { | ||
droid(id: ID!): Droid | ||
} | ||
type Droid @cacheControl(maxAge: 0) { | ||
id: ID! | ||
name: String! | ||
} | ||
`); | ||
const hints = await collectCacheControlHints( | ||
schema, | ||
` | ||
query { | ||
droid(id: 2001) { | ||
name | ||
} | ||
} | ||
`, | ||
{ defaultMaxAge: 10 }, | ||
); | ||
expect(hints).toContainEqual({ path: ['droid'], maxAge: 0 }); | ||
}); | ||
it('should override the maxAge from the target type with that specified on a field', async () => { | ||
@@ -118,0 +145,0 @@ const schema = buildSchema(` |
@@ -149,5 +149,5 @@ import { | ||
return { | ||
maxAge: otherHint.maxAge || hint.maxAge, | ||
maxAge: otherHint.maxAge !== undefined ? otherHint.maxAge : hint.maxAge, | ||
scope: otherHint.scope || hint.scope | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59782
1016