Skip to content

Commit

Permalink
Revert "Avoid duplicate cacheControl directives via `isDirectiveDef…
Browse files Browse the repository at this point in the history
…ined` (#2428)"

This reverts commit 4e84def.
  • Loading branch information
abernix committed May 31, 2019
1 parent dcab646 commit c742335
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 76 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
- `apollo-datasource-rest`: Correctly allow a TTL value of `0` to represent "not-cacheable". [PR #2588](https://github.com/apollographql/apollo-server/pull/2588)
- `apollo-datasource-rest`: Fix `Invalid argument` in IE11, when `this.headers` is `undefined`. [PR #2607](https://github.com/apollographql/apollo-server/pull/2607)

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

### v2.4.8

- 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!
Expand Down
30 changes: 13 additions & 17 deletions packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ import {
PlaygroundRenderPageOptions,
} from './playground';

import { generateSchemaHash } from './utils/schemaHash';
import { isDirectiveDefined } from './utils/isDirectiveDefined';
import createSHA from './utils/createSHA';
import { generateSchemaHash } from './utils/schemaHash';
import {
processGraphQLRequest,
GraphQLRequestContext,
Expand Down Expand Up @@ -271,22 +270,19 @@ export class ApolloServerBase {

// We augment the typeDefs with the @cacheControl directive and associated
// scope enum, so makeExecutableSchema won't fail SDL validation
augmentedTypeDefs.push(
gql`
enum CacheControlScope {
PUBLIC
PRIVATE
}
if (!isDirectiveDefined(augmentedTypeDefs, 'cacheControl')) {
augmentedTypeDefs.push(
gql`
enum CacheControlScope {
PUBLIC
PRIVATE
}
directive @cacheControl(
maxAge: Int
scope: CacheControlScope
) on FIELD_DEFINITION | OBJECT | INTERFACE
`,
);
}
directive @cacheControl(
maxAge: Int
scope: CacheControlScope
) on FIELD_DEFINITION | OBJECT | INTERFACE
`,
);

if (this.uploadsConfig) {
const { GraphQLUpload } = require('graphql-upload');
Expand Down
44 changes: 0 additions & 44 deletions packages/apollo-server-core/src/__tests__/isDirectiveDefined.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/apollo-server-core/src/utils/isDirectiveDefined.ts

This file was deleted.

0 comments on commit c742335

Please sign in to comment.