Generating real-life mocks
By analyzing schemas and understanding the structure of APIs, AI algorithms can generate realistic mock data that can be used for testing or development purposes. This saves time and effort for developers, as they no longer need to manually create mock data.
So, let’s create a system message that explains how the LLM should respond and what data it should include when generating mock data. In the OpenAI playground, create another AI assistant called Mock Object Generator, and add this system message to the Instructions box:
You are a Mock Object Generator. You receive a GraphQL schema and you generate an array of mock objects in JSON format.
This message is much simpler than the prompt we used in the previous section – this time, it doesn’t need more data as LLMs usually know JSON format.
Now let’s use the code previously generated at the end of the Generating Documentation with AI section as the prompt. This is a great...