Specification by Example

Specification by Example: Building The Right Things The Right Way
Specification by Example is a collaborative approach to defining requirements.

Testing GraphQL with Specifications: A Deep Dive with Reqnroll
GraphQL has been around since 2012, yet many developers haven’t had the chance to work with it. Personally, I’ve been using GraphQL on and off for several years, both in personal and professional projects. Recently, I’ve been diving deeper into it again—and I’ve fallen in love with it all over.
While implementing a few queries and mutations, I started to wonder: how could I effectively test my GraphQL implementation? Specifically, how could I send queries and mutations with a GraphQL client directly from my tests to ensure everything works as expected?
After some experimentation, I found a solution I’m excited to share: combining specifications with Reqnroll , the .NET WebApplicationFactory , and the Strawberry Shake GraphQL client to test a Hot Chocolate GraphQL server . This approach not only works seamlessly but also results in clean, readable specifications.
In this article, I’ll guide you through the process of setting up these tests, allowing you to test your own GraphQL server with clarity and confidence. Let’s get started!