-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve Resolvers plugins #1593
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
Conversation
Nice work!! So with this schema: type MyType {
foo: String!
otherType: MyOtherType
}
type MyOtherType {
bar: String!
}
type Query {
something: MyType!
} We would by default get: type ResolversTypes = {
Query: Omit<Query, 'something'> & { something: ResolversTypes['MyType'] },
MyType: Omit<MyType, 'otherType'> & { otherType: Maybe<ResolversTypes['MyOtherType']> },
String: Scalars['String'],
MyOtherType: MyOtherType,
} This looks awesome since the return values of the resolvers now are recursively defined with it's own types instead of the original schema types. My question is how we would make a Partial of MyType: 'Partial<MyType>' But I guess then I would get: type ResolversTypes = {
Query: Omit<Query, 'something'> & { something: ResolversTypes['MyType'] },
MyType: Partial<MyType>,
String: Scalars['String'],
MyOtherType: MyOtherType,
} So I would get a partial of the orignal type ResolversTypes = {
Query: Omit<Query, 'something'> & { something: ResolversTypes['MyType'] },
MyType: Partial<Omit<MyType, 'otherType'> & { otherType: Maybe<ResolversTypes['MyOtherType']> }>,
String: Scalars['String'],
MyOtherType: MyOtherType,
} I'm not sure how but perhaps it would be possible to make the recursively defined resolver types available for additional mapping? Or maybe I am misunderstanding how it is supposed to work. Anyway, keep up the good work :-). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, except it doesn't set a custom type on a nested usage when defaultMapper
is Partial<{T}>
. I added a test for that
Regarding my previous comment, perhaps something like this would be possible. Types specified in mappers is put in export type MapperTypes = {
readonly MyType: Partial<ResolversTypes["MyType"]>,
readonly MyOtherType: ResolversTypes["MyOtherType"],
}
export type ResolversTypes = {
readonly Query: Omit<Query, 'something'> & { readonly something: MapperTypes['MyType'] },
readonly MyType: Omit<MyType, 'otherType'> & { readonly otherType: Maybe<MapperTypes['MyOtherType']> },
readonly String: string,
readonly MyOtherType: MyOtherType,
}; I don't really like it though since it becomes more complex and also it is not clear if types from |
403f93b
to
ac1bcb9
Compare
@jonaskello We aim for replacing a type with another type in the level of its declaration, and not in the level of its usage, because we don't want to map fields, but types. Regarding The priority |
@dotansimha Yes, I agree on the added complexity. Ideally we would have the possibility to use the Omitted types without adding complexity but I don't see a solution for that right now. Anyway, the changes in this PR is a big step forward for resolver typings without that possibility 👍 |
d17a757
to
2b1b1cc
Compare
Looks good 👍 |
Looks like this hasn't landed yet. Any idea on when the next release will be? |
Hi @mshwery |
This PR will resolve the following issues related to resolvers packages:
unusedMappers
config to the base package