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

feat: JWTExtendContextFields should receive generics #302

Open
jjangga0214 opened this issue Dec 9, 2024 · 0 comments
Open

feat: JWTExtendContextFields should receive generics #302

jjangga0214 opened this issue Dec 9, 2024 · 0 comments

Comments

@jjangga0214
Copy link

jjangga0214 commented Dec 9, 2024

Hi!

I have a yoga subgraph.
I decode JWT payload from the gateway, and the subgraph consumes it as context.

import { YogaInitialContext } from 'graphql-yoga'
import { JWTExtendContextFields } from '@graphql-hive/gateway'

export interface GraphQLContext extends YogaInitialContext {
  jwt: JWTExtendContextFields
}

And JWTExtendContextFields is declared like this.

export type JWTExtendContextFields = {
  payload: JwtPayload;
  token: {
      value: string;
      prefix?: string;
  };
};

The problem is that JwtPayload is fixed.
So I cannot extend it to contain my own payload properties.
It should be conceptually like this.

export type JWTExtendContextFields<T = {}> = {
  payload: JwtPayload<T>;
  token: {
      value: string;
      prefix?: string;
  };
};
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

No branches or pull requests

1 participant