Skip to content

Commit

Permalink
batch stitching
Browse files Browse the repository at this point in the history
  • Loading branch information
Warxcell committed Feb 10, 2023
1 parent 8cb1bc6 commit 5790275
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/api2/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
type Query {
getObjectById(id: ID!): Object2!

getObjectsByIds(ids: [ID!]!): [Object2!]!
}

type Object2 {
Expand Down
11 changes: 11 additions & 0 deletions src/api2/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ export default makeExecutableSchema({
Query: {
getObjectById: () => {
throw new Error('test');
},
getObjectsByIds: () => {
return [
{
id: 1,
anotherRelation: {
id: 5,
isActive: true
}
}
]
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const resolvers: Resolvers = {
relation: {
fragment: '{ relationId }',
resolve: async (root, args, context, info) => {
return context.Api2.Query.getObjectById({
return context.Api2.Query.getObjectsByIds({
root,
context,
info,
args: {
id: root.relationId
}
key: root.relationId,
argsFromKeys: (keys) => ({ids: keys}),
}).then((data) => {
console.log(data);
if (!data.anotherRelation.isActive) {
Expand Down

0 comments on commit 5790275

Please sign in to comment.