Skip to content

feat(@graphql-yoga/plugin-jwt): add generics to JWTExtendContextFields #3529

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjangga0214
Copy link

@jjangga0214 jjangga0214 commented Dec 9, 2024

Ref GW-29

Refer to graphql-hive/gateway#302

Copy link

changeset-bot bot commented Dec 9, 2024

⚠️ No Changeset found

Latest commit: ca9d18b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jjangga0214 jjangga0214 changed the title feat(@graphql-yoga/plugin-jwt): JWTExtendContextFields feat(@graphql-yoga/plugin-jwt): add generics to JWTExtendContextFields Dec 9, 2024
@ardatan ardatan requested review from enisdenjo and n1ru4l December 9, 2024 10:50
type ExtendableJwtPayload<T extends Record<string, any> = Record<string, never>> = JwtPayload & T;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type JWTExtendContextFields<T extends Record<string, any> = Record<string, never>> = {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't making this Record<string, never> a breaking change?
Because users from previous versions would get an error with regular objects, no?

Copy link
Member

Choose a reason for hiding this comment

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

Yes exactly. This should be Record<string, any>.

export type JWTExtendContextFields = {
payload: JwtPayload;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type ExtendableJwtPayload<T extends Record<string, any> = Record<string, never>> = JwtPayload & T;
Copy link
Member

@ardatan ardatan Jan 3, 2025

Choose a reason for hiding this comment

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

Suggested change
type ExtendableJwtPayload<T extends Record<string, any> = Record<string, never>> = JwtPayload & T;
type ExtendableJwtPayload<T extends Record<string, any> = Record<string, any>> = JwtPayload & T;

https://github.com/dotansimha/graphql-yoga/pull/3529/files#r1875898366

type ExtendableJwtPayload<T extends Record<string, any> = Record<string, never>> = JwtPayload & T;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type JWTExtendContextFields<T extends Record<string, any> = Record<string, never>> = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export type JWTExtendContextFields<T extends Record<string, any> = Record<string, never>> = {
export type JWTExtendContextFields<T extends Record<string, any> = Record<string, any>> = {

https://github.com/dotansimha/graphql-yoga/pull/3529/files#r1875898366

Copy link
Member

@enisdenjo enisdenjo left a comment

Choose a reason for hiding this comment

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

After addressing @ardatan comments, we're good to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants