Skip to content

Commit 37407c4

Browse files
committed
Wire up cache-control-types and gateway-interface packages to
repo, start building c-c-t for cjs+esm
1 parent 0d47edb commit 37407c4

18 files changed

Lines changed: 107 additions & 53 deletions

File tree

.changeset/beige-feet-destroy.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

package-lock.json

Lines changed: 49 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"npm": "^8.5.0"
4141
},
4242
"devDependencies": {
43-
"@apollo/cache-control-types": "1.0.2",
4443
"@apollo/client": "3.7.0",
4544
"@apollo/server-plugin-landing-page-graphql-playground": "4.0.0",
4645
"@apollo/utils.createhash": "1.1.0",

packages/cache-control-types/package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
"name": "@apollo/cache-control-types",
33
"version": "1.0.2",
44
"description": "TypeScript types for Apollo Server info.cacheControl",
5-
"main": "dist/index.js",
6-
"types": "dist/index.d.ts",
5+
"type": "module",
6+
"main": "dist/cjs/index.js",
7+
"module": "dist/esm/index.js",
8+
"types": "dist/esm/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/esm/index.d.ts",
12+
"import": "./dist/esm/index.js",
13+
"require": "./dist/cjs/index.js"
14+
}
15+
},
716
"repository": {
817
"type": "git",
9-
"url": "git+https://github.com/apollographql/apollo-utils.git",
18+
"url": "git+https://github.com/apollographql/apollo-server.git",
1019
"directory": "packages/cache-control-types/"
1120
},
1221
"keywords": [
@@ -17,6 +26,10 @@
1726
],
1827
"author": "Apollo <packages@apollographql.com>",
1928
"license": "MIT",
29+
"bugs": {
30+
"url": "https://github.com/apollographql/apollo-server/issues"
31+
},
32+
"homepage": "https://github.com/apollographql/apollo-server#readme",
2033
"peerDependencies": {
2134
"graphql": "14.x || 15.x || 16.x"
2235
}

packages/cache-control-types/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
// enable us to make non-alpha releases that can be used on the apollo-server
44
// version-4 branch.
55

6-
import type { GraphQLCompositeType, GraphQLResolveInfo } from "graphql";
6+
import type { GraphQLCompositeType, GraphQLResolveInfo } from 'graphql';
77

88
/**
99
* CacheScope represents whether cacheable data should be shared across sessions
1010
* (PUBLIC) or considered session-specific (PRIVATE).
1111
*/
12-
export type CacheScope = "PUBLIC" | "PRIVATE";
12+
export type CacheScope = 'PUBLIC' | 'PRIVATE';
1313

1414
/**
1515
* CacheHint represents a contribution to an overall cache policy. It can
@@ -63,7 +63,7 @@ export interface ResolveInfoCacheControl {
6363
* use this type with the customResolveInfo option to the graphql-code-generator
6464
* typescript-resolvers plugin, for example.) */
6565
export interface GraphQLResolveInfoWithCacheControl
66-
extends Omit<GraphQLResolveInfo, "cacheControl"> {
66+
extends Omit<GraphQLResolveInfo, 'cacheControl'> {
6767
// Why the Omit above? If you happen to have AS2 `apollo-cache-control` or AS3
6868
// `apollo-server-core` in your TypeScript build, then there's an ambient
6969
// `declare module` floating around that monkey-patches GraphQLResolveInfo to
@@ -96,18 +96,18 @@ export function maybeCacheControlFromInfo(
9696
export function cacheControlFromInfo(
9797
info: GraphQLResolveInfo,
9898
): ResolveInfoCacheControl {
99-
if (!("cacheControl" in info)) {
99+
if (!('cacheControl' in info)) {
100100
throw new Error(
101-
"The `info` argument does not appear to have a cacheControl field. " +
101+
'The `info` argument does not appear to have a cacheControl field. ' +
102102
"Check that you are using Apollo Server 3 or newer and that you aren't using " +
103-
"ApolloServerPluginCacheControlDisabled.",
103+
'ApolloServerPluginCacheControlDisabled.',
104104
);
105105
}
106106
if (!(info as any).cacheControl?.cacheHint?.restrict) {
107107
throw new Error(
108-
"The `info` argument has a cacheControl field but it does not appear to be from Apollo" +
108+
'The `info` argument has a cacheControl field but it does not appear to be from Apollo' +
109109
"Server 3 or newer. Check that you are using Apollo Server 3 or newer and that you aren't using " +
110-
"ApolloServerPluginCacheControlDisabled.",
110+
'ApolloServerPluginCacheControlDisabled.',
111111
);
112112
}
113113
return (info as any).cacheControl;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ".",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs",
6+
// We delete the CJS .d.ts files in postcompile so we don't need to
7+
// ever make their maps. (We can't disable creating the files because
8+
// this is a composite project.)
9+
"declarationMap": false,
10+
},
11+
}

packages/cache-control-types/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.base",
33
"compilerOptions": {
44
"rootDir": "src",
5-
"outDir": "dist"
5+
"outDir": "dist/esm"
66
},
77
"include": ["src/**/*"],
88
"exclude": ["**/__tests__"]
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)