Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly type extensions in GraphQLFormattedError #4286

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

tpoisseau
Copy link
Contributor

Following typescript documentation, it's not possible override interface property, we can only add new props.

Since it's declared as unknown dict, even if we merge GraphQLErrorExtensions, we can't access to our extensions without workaround and verbose typescript in source-code.

It's annoying since apollo expose GraphQLFormattedError instead GraphQLError

Refs: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789

Following typescript documentation, it's not possible override interface property, we can only add new props.

Since it's declared as unknown dict, even if we merge `GraphQLErrorExtensions`, we can't access to our extensions without workaround and verbose typescript in source-code.

It's annoying since apollo expose `GraphQLFormattedError` instead `GraphQLError`

Refs: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789
@tpoisseau tpoisseau requested a review from a team as a code owner November 6, 2024 09:14
Copy link

linux-foundation-easycla bot commented Nov 6, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

github-actions bot commented Nov 6, 2024

Hi @tpoisseau, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

src/error/GraphQLError.ts Outdated Show resolved Hide resolved
Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general idea behind this looks good to me, I did have one thought which is mainly testing related. Currently it looks like the strict typing won't be applied to manually creating a GraphQLError however due to the loosely typed nature of it it won't block you. Just wanted to highlight that currently this static typing will only apply to the result type.

I've marked this as a feature, as this allows you to overwrite this to make your type more strict.

@JoviDeCroock JoviDeCroock added the PR: feature 🚀 requires increase of "minor" version number label Nov 8, 2024
@JoviDeCroock JoviDeCroock merged commit 3f49961 into graphql:16.x.x Nov 8, 2024
17 checks passed
yaacovCR pushed a commit to yaacovCR/graphql-js that referenced this pull request Nov 26, 2024
Following typescript documentation, it's not possible override interface
property, we can only add new props.

Since it's declared as unknown dict, even if we merge
`GraphQLErrorExtensions`, we can't access to our extensions without
workaround and verbose typescript in source-code.

It's annoying since apollo expose `GraphQLFormattedError` instead
`GraphQLError`

Refs:
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789
yaacovCR pushed a commit to yaacovCR/graphql-js that referenced this pull request Dec 3, 2024
Following typescript documentation, it's not possible override interface
property, we can only add new props.

Since it's declared as unknown dict, even if we merge
`GraphQLErrorExtensions`, we can't access to our extensions without
workaround and verbose typescript in source-code.

It's annoying since apollo expose `GraphQLFormattedError` instead
`GraphQLError`

Refs:
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789
yaacovCR pushed a commit to yaacovCR/graphql-js that referenced this pull request Dec 3, 2024
Following typescript documentation, it's not possible override interface
property, we can only add new props.

Since it's declared as unknown dict, even if we merge
`GraphQLErrorExtensions`, we can't access to our extensions without
workaround and verbose typescript in source-code.

It's annoying since apollo expose `GraphQLFormattedError` instead
`GraphQLError`

Refs:
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789
yaacovCR pushed a commit to yaacovCR/graphql-js that referenced this pull request Dec 3, 2024
Following typescript documentation, it's not possible override interface
property, we can only add new props.

Since it's declared as unknown dict, even if we merge
`GraphQLErrorExtensions`, we can't access to our extensions without
workaround and verbose typescript in source-code.

It's annoying since apollo expose `GraphQLFormattedError` instead
`GraphQLError`

Refs:
https://www.typescriptlang.org/docs/handbook/declaration-merging.html
Refs: apollographql/apollo-client#11789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature 🚀 requires increase of "minor" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants