Event sourcing allows you to view your data at any point in time, and gives you a transparent audit log of all the events that led to the current state of the system. In other words, it allows your queries to travel through time and look through historical states of your objects.
In an eventsourced system, we can model all changes to any entity as events, and this allows us to do so called temporal queries (aka query into past states of the system). When mixed with GraphQL, this creates a powerful state machine that can be used to provide rich insights into data, while still providing all the benefits of GraphQL. All of this can be accomplished without the use of any frameworks and with any GraphQL implementation.
Take the example of an online directory that lists a bunch of restaurants. As time goes on, restaurants change their phone numbers, addresses etc. We want to be able to answer questions like: - What was the name of that restaurant that served american-style pancakes on ABC street but then it moved to XYZ street? - I wonder how long that pancake restaurant has been in business? - I wonder how many times this foodtruck has moved locations in the last 5 years? - Didn’t this restaurant use to serve asian food two years ago?
Why I am the best person to speak on this subject:
For the last 1½ years, I’ve been part of a project where we designed and implemented an event sourcing system with a graphql API on top. In addition to having a system that was searchable across time and state transitions, we also got a system where our graphql schema never dictated the structure of how we save our data and vice-versa, which allowed us to adapt much more rapidly to frontend requirements.
I can also add that I started public speaking at the age of 17, and in the last two years I have been moving into giving technical talks (including a talk at GraphQL Berlin - “Practical drills for aspiring speakers”)
Technical requirements (for the talk):
Only a projector is required
Structure of the talk (agenda):
- Introduction to eventsourcing
- Aggregates and entities
- Applying events to an aggregate
- Transforming aggregates to read models
- Introduction to projections
- Example of Projection for restaurants
- The downsides
- Event sourced systems are more complex
- No more ad-hoc fixing of production data