Generating realistic mock GraphQL data has been a persistent industry challenge. Airbnb developed a solution using a new GraphQL client directive, @generateMock, to automate this process. This directive allows engineers to add context and design URLs to their GraphQL operations. The Niobe command-line tool integrates this directive into the code generation workflow. Niobe collects query details, schema context, and design information to create prompts for Large Language Models. The Gemini 2.5 Pro model is used due to its large context window and efficient performance. After LLM generation, the mock data undergoes validation against the GraphQL schema to ensure type safety. If validation fails, the errors are fed back to the LLM for correction, creating a self-healing mechanism. This approach eliminates manual mock creation, saving engineers time and effort. The generated mocks are highly realistic, matching design mockups and improving prototyping and testing capabilities.
medium.com
medium.com
Create attached notes ...
