forked from dgraph-io/dgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (20 loc) · 688 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (20 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fullName = ({ parent: { firstName, lastName } }) =>
`${firstName} ${lastName}`;
async function todoTitles({ graphql }) {
const results = await graphql("{ queryTodo { title } }");
return results.data.queryTodo.map((t) => t.title);
}
self.addGraphQLResolvers({
"User.fullName": fullName,
"Query.todoTitles": todoTitles,
});
async function reallyComplexDql({ parents, dql }) {
const ids = parents.map((p) => p.id);
const someComplexResults = await dql.query(
`really-complex-query-here with ${ids}`
);
return parents.map((parent) => someComplexResults[parent.id]);
}
self.addMultiParentGraphQLResolvers({
"User.reallyComplexProperty": reallyComplexDql,
});