Skip to content

Commit

Permalink
Upgrade typescript version and resolve "unconstrained generic" erro…
Browse files Browse the repository at this point in the history
…rs (#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.
-->
  • Loading branch information
trevor-scheer authored Sep 23, 2022
1 parent 89e8463 commit ca928e4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"supertest": "6.2.4",
"test-listen": "1.1.0",
"ts-jest": "28.0.8",
"typescript": "4.7.4"
"typescript": "4.8.3"
},
"jest": {
"projects": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
GraphQLServiceContext,
GraphQLRequestContextDidResolveOperation,
GraphQLRequestContextWillSendResponse,
BaseContext,
} from 'apollo-server-types';
import {
createOperationDerivedDataCache,
Expand Down Expand Up @@ -63,7 +64,7 @@ class ReportData {
}
}

export function ApolloServerPluginUsageReporting<TContext>(
export function ApolloServerPluginUsageReporting<TContext extends BaseContext>(
options: ApolloServerPluginUsageReportingOptions<TContext> = Object.create(
null,
),
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-server-core/src/requestPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
GraphQLExecutor,
GraphQLExecutionResult,
ValidationRule,
BaseContext,
} from 'apollo-server-types';
import type {
ApolloServerPlugin,
Expand Down Expand Up @@ -117,7 +118,7 @@ function isBadUserInputGraphQLError(error: GraphQLError): Boolean {
);
}

export async function processGraphQLRequest<TContext>(
export async function processGraphQLRequest<TContext extends BaseContext>(
config: GraphQLRequestPipelineConfig<TContext>,
requestContext: Mutable<GraphQLRequestContext<TContext>>,
): Promise<GraphQLResponse> {
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-server-core/src/runHttpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Headers, Request } from 'apollo-server-env';
import { ApolloError, formatApolloErrors } from 'apollo-server-errors';
import type { ApolloServerPlugin } from 'apollo-server-plugin-base';
import type {
BaseContext,
GraphQLExecutionResult,
ValueOrPromise,
WithRequired,
Expand Down Expand Up @@ -290,7 +291,7 @@ export async function runHttpQuery(
return processHTTPRequest(config, request);
}

export async function processHTTPRequest<TContext>(
export async function processHTTPRequest<TContext extends BaseContext>(
options: WithRequired<GraphQLOptions<TContext>, 'cache' | 'plugins'> & {
context: TContext;
},
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-server-core/src/utils/pluginTestHarness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
GraphQLRequestContextParsingDidStart,
GraphQLRequestContextValidationDidStart,
SchemaHash,
BaseContext,
} from 'apollo-server-types';
import type { Logger } from '@apollo/utils.logger';
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from 'graphql/type';
Expand All @@ -35,7 +36,7 @@ type IPluginTestHarnessExecutionDidStart<TContext> =
request: IPluginTestHarnessGraphqlRequest;
};

export default async function pluginTestHarness<TContext>({
export default async function pluginTestHarness<TContext extends BaseContext>({
pluginInstance,
schema,
logger,
Expand Down
9 changes: 1 addition & 8 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@
matchPackageNames: ["jest", "jest-config", "ts-jest", "@types/jest", ],
matchBaseBranches: ["main"],
allowedVersions: "28.x"
},
{
// typescript@4.8 breaks the build on main; since AS4 is imminent, pinning
// seems better than fixing.
matchPackageNames: ["typescript"],
matchBaseBranches: ["main"],
allowedVersions: "4.7.x",
},
}
]
}

0 comments on commit ca928e4

Please sign in to comment.