Hi,
I am trying out the push the types in resolvers to the limit with new options :-).
In my use case TParent is usually needed to retype to the model types (as often some additional fields that are not exposed via graphql are being used), but that still looks very good as it can be nicely defined per graphql type, like this :
type Study {
_id: ObjectId!
ready: Bool!
studyDescription: StudyDescription!
referringPhysicians: [ReferringPhysician]!
}
const studyResolvers: GQLStudyTypeResolver<MStudy> = {
referringPhysicians(study, {}, ctx) {
return loadReferringPhysicianByIds(ctx, study.referringPhysicianIds);
},
studyDescription(study, {}, ctx) {
if (!study.studyDescriptionId) {
return null;
}
return loadStudyDescriptionById(ctx, study.studyDescriptionId);
},
};
But thinking about following improvement that I believe could make the result type significantly more useful, don't know how difficult be to add that in.
In this example smartTResult type requires that resolver which is returning GQLStudy would have return all fields (_id, read, studyDescription and referringPhysicians), but in fact since Study type has own resolvers for referringPhysicians and studyDescription ideally it should not require these fields (make them optional) when resolving Study type and require only _id and ready.
That would require to not just look at what type is being returned, but also look into the resolvers if there are some field resolvers.
What do you think, does it make sense?
Hi,
I am trying out the push the types in resolvers to the limit with new options :-).
In my use case TParent is usually needed to retype to the model types (as often some additional fields that are not exposed via graphql are being used), but that still looks very good as it can be nicely defined per graphql type, like this :
But thinking about following improvement that I believe could make the result type significantly more useful, don't know how difficult be to add that in.
In this example smartTResult type requires that resolver which is returning GQLStudy would have return all fields (_id, read, studyDescription and referringPhysicians), but in fact since Study type has own resolvers for
referringPhysiciansandstudyDescriptionideally it should not require these fields (make them optional) when resolving Study type and require only_idandready.That would require to not just look at what type is being returned, but also look into the resolvers if there are some field resolvers.
What do you think, does it make sense?