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

Improve typings #66

Open
djflex68 opened this issue Oct 1, 2019 · 1 comment
Open

Improve typings #66

djflex68 opened this issue Oct 1, 2019 · 1 comment

Comments

@djflex68
Copy link

djflex68 commented Oct 1, 2019

Hello,

I'm wondering if there is a way to improve the typings definition by having the context variable being typed :

export interface ResultFunction<ResulType> {
    (root: any, args: any, context: any, info: any): Promise<ResulType> | ResulType | void;
}

becomes

export interface ResultFunction<ResulType, ContextType> {
    (root: any, args: any, context: ContextType, info: any): Promise<ResulType> | ResulType | void;
}

The idea behind that is that if we make some modifications on the context object (like adding new properties that would be needed by the next resolver in the pipe), we would then be able to retrieve a fully typed variable in the next resolver, instead of any.
In a perfect world, each resolver context type should augment the previous one, so that the last resolver gets a merged type of all added properties.

Thanks

@thebigredgeek
Copy link
Owner

#67

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

2 participants