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
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,7 @@ UserTC.addRelation(
182
182
}
183
183
);
184
184
```
185
+
185
186
### Reusing the same mongoose Schema in embedded object fields
186
187
Suppose you have a common structure you use as embedded object in multiple Schemas.
187
188
Also suppose you want the structure to have the same GraphQL type across all parent types.
@@ -252,6 +253,74 @@ fragment fullImageData on EmbeddedImage {
252
253
}
253
254
```
254
255
256
+
### Access and modify mongoose doc before save
257
+
This library provides some amount of ready resolvers for fetch and update data which was mentioned above. And you can [create your own resolver](https://github.com/graphql-compose/graphql-compose) of course. However you can find that add some actions or light modifications of mongoose document directly before save at existing resolvers appears more simple than create new resolver. Some of resolvers accepts *before save hook* wich can be provided in *resolver params* as param named `beforeRecordMutate`. This hook allows to have access and modify mongoose document before save. The resolvers which supports this hook are:
When we convert model `const UserTC = composeWithMongoose(User, customizationOptions);` you may tune every piece of future derived types and resolvers.
0 commit comments