From feecaca948e68734d621f44d8ab2620e9b3fd78f Mon Sep 17 00:00:00 2001 From: Trevor Scheer Date: Wed, 7 Aug 2024 08:27:04 -0700 Subject: [PATCH] add one more case for type without cachecontrol implementing interface with cachecontrol --- .../cacheControlDirective.test.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/server/src/__tests__/plugin/cacheControl/cacheControlDirective.test.ts b/packages/server/src/__tests__/plugin/cacheControl/cacheControlDirective.test.ts index b852d683ea5..062836a9b20 100644 --- a/packages/server/src/__tests__/plugin/cacheControl/cacheControlDirective.test.ts +++ b/packages/server/src/__tests__/plugin/cacheControl/cacheControlDirective.test.ts @@ -280,8 +280,13 @@ describe('@cacheControl directives', () => { it('interaction between type implementing interface, both with specified `maxAge`', async () => { const schema = buildSchemaWithCacheControlSupport(` type Query { - droid(id: ID!): Droid named: Named + droid(id: ID!): Droid + alien(id: ID!): Alien + } + + interface Named @cacheControl(maxAge: 60) { + name: String! } type Droid implements Named @cacheControl(maxAge: 30) { @@ -289,7 +294,8 @@ describe('@cacheControl directives', () => { name: String! } - interface Named @cacheControl(maxAge: 60) { + type Alien implements Named { + id: ID! name: String! } `); @@ -327,6 +333,23 @@ describe('@cacheControl directives', () => { expect(hintsDroid).toStrictEqual( new Map([['droid', { maxAge: 30, scope: undefined }]]), ); + + const hintsAlien = await collectCacheControlHints( + schema, + ` + query { + alien(id: 3001) { + id + name + } + } + `, + { defaultMaxAge: 10 } + ); + + expect(hintsAlien).toStrictEqual( + new Map([['alien', { maxAge: 10, scope: undefined }]]), + ); }); it('inheritMaxAge', async () => {