Skip to content

Commit ca928e4

Browse files
Upgrade typescript version and resolve "unconstrained generic" errors (#6940)
Similar to ardatan/graphql-tools#4382, but these didn't turn up in the 4.7 upgrade. Likely related to microsoft/TypeScript#49489. Solution is to constrain our generics appropriately. <!-- First, 🌠 thank you 🌠 for taking the time to consider a contribution to Apollo! Here are some important details to follow: * ⏰ Your time is important To save your precious time, if the contribution you are making will take more than an hour, please make sure it has been discussed in an issue first. This is especially true for feature requests! * 💡 Features Feature requests can be created and discussed within a GitHub Issue. Be sure to search for existing feature requests (and related issues!) prior to opening a new request. If an existing issue covers the need, please upvote that issue by using the 👍 emote, rather than opening a new issue. * 🔌 Integrations Apollo Server has many web-framework integrations including Express, Koa, Hapi and more. When adding a new feature, or fixing a bug, please take a peak and see if other integrations are also affected. In most cases, the fix can be applied to the other frameworks as well. Please note that, since new web-frameworks have a high maintenance cost, pull-requests for new web-frameworks should be discussed with a project maintainer first. * 🕷 Bug fixes These can be created and discussed in this repository. When fixing a bug, please _try_ to add a test which verifies the fix. If you cannot, you should still submit the PR but we may still ask you (and help you!) to create a test. * 📖 Contribution guidelines Follow https://github.com/apollographql/apollo-server/blob/main/CONTRIBUTING.md when submitting a pull request. Make sure existing tests still pass, and add tests for all new behavior. * ✏️ Explain your pull request Describe the big picture of your changes here to communicate to what your pull request is meant to accomplish. Provide 🔗 links 🔗 to associated issues! We hope you will find this to be a positive experience! Open source contribution can be intimidating and we hope to alleviate that pain as much as possible. Without following these guidelines, you may be missing context that can help you succeed with your contribution, which is why we encourage discussion first. Ultimately, there is no guarantee that we will be able to merge your pull-request, but by following these guidelines we can try to avoid disappointment. -->
1 parent 89e8463 commit ca928e4

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"supertest": "6.2.4",
126126
"test-listen": "1.1.0",
127127
"ts-jest": "28.0.8",
128-
"typescript": "4.7.4"
128+
"typescript": "4.8.3"
129129
},
130130
"jest": {
131131
"projects": [

packages/apollo-server-core/src/plugin/usageReporting/plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
GraphQLServiceContext,
1414
GraphQLRequestContextDidResolveOperation,
1515
GraphQLRequestContextWillSendResponse,
16+
BaseContext,
1617
} from 'apollo-server-types';
1718
import {
1819
createOperationDerivedDataCache,
@@ -63,7 +64,7 @@ class ReportData {
6364
}
6465
}
6566

66-
export function ApolloServerPluginUsageReporting<TContext>(
67+
export function ApolloServerPluginUsageReporting<TContext extends BaseContext>(
6768
options: ApolloServerPluginUsageReportingOptions<TContext> = Object.create(
6869
null,
6970
),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import type {
3737
GraphQLExecutor,
3838
GraphQLExecutionResult,
3939
ValidationRule,
40+
BaseContext,
4041
} from 'apollo-server-types';
4142
import type {
4243
ApolloServerPlugin,
@@ -117,7 +118,7 @@ function isBadUserInputGraphQLError(error: GraphQLError): Boolean {
117118
);
118119
}
119120

120-
export async function processGraphQLRequest<TContext>(
121+
export async function processGraphQLRequest<TContext extends BaseContext>(
121122
config: GraphQLRequestPipelineConfig<TContext>,
122123
requestContext: Mutable<GraphQLRequestContext<TContext>>,
123124
): Promise<GraphQLResponse> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Headers, Request } from 'apollo-server-env';
22
import { ApolloError, formatApolloErrors } from 'apollo-server-errors';
33
import type { ApolloServerPlugin } from 'apollo-server-plugin-base';
44
import type {
5+
BaseContext,
56
GraphQLExecutionResult,
67
ValueOrPromise,
78
WithRequired,
@@ -290,7 +291,7 @@ export async function runHttpQuery(
290291
return processHTTPRequest(config, request);
291292
}
292293

293-
export async function processHTTPRequest<TContext>(
294+
export async function processHTTPRequest<TContext extends BaseContext>(
294295
options: WithRequired<GraphQLOptions<TContext>, 'cache' | 'plugins'> & {
295296
context: TContext;
296297
},

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
GraphQLRequestContextParsingDidStart,
1212
GraphQLRequestContextValidationDidStart,
1313
SchemaHash,
14+
BaseContext,
1415
} from 'apollo-server-types';
1516
import type { Logger } from '@apollo/utils.logger';
1617
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql/type';
@@ -35,7 +36,7 @@ type IPluginTestHarnessExecutionDidStart<TContext> =
3536
request: IPluginTestHarnessGraphqlRequest;
3637
};
3738

38-
export default async function pluginTestHarness<TContext>({
39+
export default async function pluginTestHarness<TContext extends BaseContext>({
3940
pluginInstance,
4041
schema,
4142
logger,

renovate.json5

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@
168168
matchPackageNames: ["jest", "jest-config", "ts-jest", "@types/jest", ],
169169
matchBaseBranches: ["main"],
170170
allowedVersions: "28.x"
171-
},
172-
{
173-
// typescript@4.8 breaks the build on main; since AS4 is imminent, pinning
174-
// seems better than fixing.
175-
matchPackageNames: ["typescript"],
176-
matchBaseBranches: ["main"],
177-
allowedVersions: "4.7.x",
178-
},
171+
}
179172
]
180173
}

0 commit comments

Comments
 (0)