graphql-compose / graphql-compose/graphql-compose-mongoose
Create multiple Objects upon the create of Master Object?
- Dominant language
- TypeScript
- Stars
- 706
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
First off, I'm going to apologize from the get go, I'm more of a front end guy than a DBA. That said I've taken it upon myself to convert our startup's data API from MongoDB to MongoDB with GraphQL API.
Secondly and most importantly, I have to applaud you all on an amazingly slick tool. After just a few days of learning/ playing with it, our basic schema has been converted and I'm now venturing into more advanced territories. However, I've run aground on a certain approach and need some help.
**PROBLEM:**
When a user is created we would like to create/mutate 3 other objects and then tie them to the user object. They will basically be rendered with default options.
(i.e. Mailbox defaults with an empty inbox, sent and deleted schema as well as a dynamic folder for later use. )
These 3 Objects will be persistent to every user in our app and we could certainly use code to create them and then create the relationships using the addRelationship function but I think it might be better to do it all with GraphQL-Compose upon the creation of the user, it just seems more clean. The objects we would like to create are:
1. A Mailbox Object, to store messages
2. Media Library Object, to store media
3. A Profile Object to store user info outside of the user object.
We would then like to take those Objects and create a relationship to the User Object. So finally, here are the questions/problems I'm battling:
1st: Should we do this with GraphQL-Compose?
2nd: How do we create the Objects once the User has been created?
3rd: How do we remove the objects if the User is deleted?
My initial thought was to create them by calling the createOne resolver once the user is successfully created, then upon their creation, addRelation to the User Object and the newly created Objects.
Id this on the right track? If so or if not, could anyone drop me an example?
Any help on this would be tremendous and greatly appreciated!
Thanks,
John Kesler
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.