Skip to content

Commit c742335

Browse files
committed
Revert "Avoid duplicate cacheControl directives via isDirectiveDefined (#2428)"
This reverts commit 4e84def.
1 parent dcab646 commit c742335

4 files changed

Lines changed: 13 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
- `apollo-datasource-rest`: Correctly allow a TTL value of `0` to represent "not-cacheable". [PR #2588](https://github.com/apollographql/apollo-server/pull/2588)
3636
- `apollo-datasource-rest`: Fix `Invalid argument` in IE11, when `this.headers` is `undefined`. [PR #2607](https://github.com/apollographql/apollo-server/pull/2607)
3737

38-
- Don't add `cacheControl` directive if one has already been defined. [PR #2428](https://github.com/apollographql/apollo-server/pull/2428)
39-
4038
### v2.4.8
4139

4240
- No functional changes in this version. The patch version has been bumped to fix the `README.md` displayed on the [npm package for `apollo-server`](https://npm.im/apollo-server) as a result of a broken publish. Apologies for the additional noise!

packages/apollo-server-core/src/ApolloServer.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ import {
5050
PlaygroundRenderPageOptions,
5151
} from './playground';
5252

53-
import { generateSchemaHash } from './utils/schemaHash';
54-
import { isDirectiveDefined } from './utils/isDirectiveDefined';
5553
import createSHA from './utils/createSHA';
54+
import { generateSchemaHash } from './utils/schemaHash';
5655
import {
5756
processGraphQLRequest,
5857
GraphQLRequestContext,
@@ -271,22 +270,19 @@ export class ApolloServerBase {
271270

272271
// We augment the typeDefs with the @cacheControl directive and associated
273272
// scope enum, so makeExecutableSchema won't fail SDL validation
273+
augmentedTypeDefs.push(
274+
gql`
275+
enum CacheControlScope {
276+
PUBLIC
277+
PRIVATE
278+
}
274279
275-
if (!isDirectiveDefined(augmentedTypeDefs, 'cacheControl')) {
276-
augmentedTypeDefs.push(
277-
gql`
278-
enum CacheControlScope {
279-
PUBLIC
280-
PRIVATE
281-
}
282-
283-
directive @cacheControl(
284-
maxAge: Int
285-
scope: CacheControlScope
286-
) on FIELD_DEFINITION | OBJECT | INTERFACE
287-
`,
288-
);
289-
}
280+
directive @cacheControl(
281+
maxAge: Int
282+
scope: CacheControlScope
283+
) on FIELD_DEFINITION | OBJECT | INTERFACE
284+
`,
285+
);
290286

291287
if (this.uploadsConfig) {
292288
const { GraphQLUpload } = require('graphql-upload');

packages/apollo-server-core/src/__tests__/isDirectiveDefined.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/apollo-server-core/src/utils/isDirectiveDefined.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)