How to make return type of resolvers partial? #6872
Replies: 3 comments 2 replies
-
|
Were you able to find a solution to this, I'm also facing a similar problem and can't find any resources online that explain how this can be achieved. |
Beta Was this translation helpful? Give feedback.
-
|
What you return from the resolver is the |
Beta Was this translation helpful? Give feedback.
-
|
I came to this question because I'm new to GraphQL and didn't know of It seems that a type structure like this would work well: interface DataObject {
id: string;
}
type RootDataObject<Type extends DataObject> = {
[Key in keyof Type]: Type[Key] extends DataObject ? PartialDataObject<Type[Key]> : Type[Key];
};
type PartialDataObject<Type extends DataObject> = Pick<Type, 'id'> & {
[Key in Exclude<keyof Type, 'id'>]?: Type[Key] extends DataObject ? Partial<Type[Key]> : Type[Key];
};This allows you to keep the entire root object intact, but any of its properties that are objects with an I'm also not entirely sure I understand the original question and that it's somewhat old now, but I'd be curious to know if anyone finds this helpful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I am using this configuration file:
Works fine but it's really annoying to cast
as any as TypeGQLevery time I want to delegate a property of the returned object to another resolver.I've also tried adding the option:
But that also modifies the parameters of my resolvers to be
Partial<Parent>or something like that.How do I go about making only the return type of the resolver Partial?
Beta Was this translation helpful? Give feedback.
All reactions