Got it working!

This commit is contained in:
2020-03-16 06:31:29 +11:00
parent a985e496a8
commit e9655f1055
3 changed files with 95 additions and 11 deletions

View File

@@ -45,7 +45,15 @@ const handler = {
//if this is a sub-query, use the parent to find the author
if (parent && parent.typeName == 'Book') {
return authors.find(a => a.books.filter(b => b.title == parent.context.title).length > 0);
const author = authors.find(a => a.books.filter(b => b.title == parent.context.title).length > 0);
//ensure only the named scalars are returned (hack)
const ret = {};
if (scalars.filter(s => s.name == 'name').length > 0) {
ret.name = author.name;
}
return [ret]; //must return an array
}
//return all authors