Most complex systems don't naturally fit within the rigid confines of CRUD. Humans tend to tame the complexity of challenging problems by understanding the problem as a series of events. Turns out, we can design our applications this way too with @eventstorming or @EventModeling.
💡1. Domain Events - Plot out all of the events that happen for the main story in your application as past-tense verbs.
For my Hackernews-like app, that looks like:
`UserCreated` => `MemberCreated` => `PostCreated` => `CommentCreated`, `CommentUpvoted`, etc.
💡2. For each Domain Event, write the Command that causes it. These are your **GraphQL mutations.**
They should be in an imperative form. If you know the name of the role/actor that performs it, you can document that as well.
💡4. Identify the top-level Federated GraphQL fields by applying Conway's Law.
Segregate the Events, Commands, and Aggregate from each other based on the relevant self-organizing teams that play a part in the story of our application.
📖Conway's Law => https://khalilstemmler.com/wiki/conways-law/ …
💡6. Finally, create our GraphQL Schema from the discovered Commands (Mutations) and Queries.
In monoliths, you can break the schema up into separate files by `extend`-ing the Query and Mutation.
For Federated apps, you can compose schemas with the `@key` directive.
Unless you're building a CRUD app, designing a GraphQL schema isn't something that should be done in isolation.
If we're working a large-scale app, we should try to get a mix of domain experts & developers together to agree on both the business process and the resulting schema.
You can follow @stemmlerjs.
Tip: mention @threader_app on a Twitter thread with the keyword “compile” to get a link to it.
Enjoy Threader? Sign up.
Threader is an independent project created by only two developers. The site gets 500,000+ visits a month and our iOS Twitter client was featured as an App of the Day by Apple. Running this space is expensive and time consuming. If you find Threader useful, please consider supporting us to make it a sustainable project.