File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ This package uses [DataLoader](https://github.com/graphql/dataloader) for batchi
20
20
- [ Basic] ( #basic )
21
21
- [ Batching] ( #batching )
22
22
- [ Caching] ( #caching )
23
+ - [ Mongoose] ( #mongoose )
23
24
- [ API] ( #api )
24
25
- [ findOneById] ( #findonebyid )
25
26
- [ findManyByIds] ( #findmanybyids )
@@ -87,6 +88,26 @@ class Users extends MongoDataSource {
87
88
}
88
89
```
89
90
91
+ ### Mongoose
92
+
93
+ You can use mongoose the same way as with the native mongodb client
94
+
95
+ ``` js
96
+ import mongoose from ' mongoose'
97
+ import Users from ' ./data-sources/Users.js'
98
+
99
+ const userSchema = new mongoose.Schema ({ name: ' string' });
100
+ const UsersModel = mongoose .model (' users' , userSchema);
101
+
102
+ const server = new ApolloServer ({
103
+ typeDefs,
104
+ resolvers,
105
+ dataSources : () => ({
106
+ db: new Users ({ users: UsersModel })
107
+ })
108
+ })
109
+ ```
110
+
90
111
### Batching
91
112
92
113
This is the main feature, and is always enabled. Here's a full example:
You can’t perform that action at this time.
0 commit comments