node.js – GraphQL resolve another resolver with projection for the related fields
Is it possible to resolve another resolver by the .resolve()
method with projection for the fields added as relations?
DataTC.addRelation("userData", {
resolver: () => UserTC.getResolver("findById"),
prepareArgs: {
_id: (source) => source.userId,
},
projection: { userId: true },
});
Above is relation. And trying to obtain userData:
const dataList = JSON.parse(
JSON.stringify(
await DataTC.getResolver("findMany").resolve({
source,
projection: {
userId,
userName,
userData: {
email: true
}
},
context,
info,
args,
}),
),
);
This query returns all native fields of the “DataTC” object type composer perfectly, but the “userData” relation is completely absent in response.
Maybe there’s some option in the configuration that could turn on related fields to be returned?
Read the docs, but was unable to find anything about querying nested fields in projection.
Thank you.
Read more here: Source link