You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+55-8Lines changed: 55 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,17 +70,64 @@ const resolver = () =>
70
70
## Experimental data loader
71
71
72
72
You can use experimental data loader for requests that can cause n+1 problem. It is still in experimental phase.
73
+
Consider the following schema
74
+
```graphql
75
+
typePerson{
76
+
id: String!
77
+
username:String!
78
+
friends: [Person!]!
79
+
}
80
+
81
+
typeQuery{
82
+
person(_id:String!): Person!
83
+
}
84
+
```
73
85
74
-
75
-
## List objects
76
-
```ts
77
-
const result =awaitMongoOrb("Source").list({})
86
+
Andthefollowingquery:
87
+
88
+
```gql
89
+
queryGetPersonWithFriends{
90
+
person(id:"38u198rh89h"){
91
+
username
92
+
id
93
+
friends{
94
+
username
95
+
id
96
+
friends{
97
+
username
98
+
id
99
+
}
100
+
}
101
+
}
102
+
}
78
103
```
79
104
80
-
This will return list of objects but also make resolved promise for each of _id contained inside list. So later during the same GraphQL query if you request some object:
105
+
Here is how you can implement to limit db calls and avoid n+1 problem
81
106
82
107
```ts
83
-
const result =awaitMongoOrb("Source").oneByPk("892194hruh8hasd")
0 commit comments