How to mock Generic types in Graphql? #3674
Unanswered
hashiromer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am mocking an existing Graphql API which is quite large (around 2000 types) with graphql tools. The API I am mocking contains a lot of queries which return a list of objects and this tool returns 2 objects for every list by default. For example, if a query returns a list of people, this tool would generate dummy data for two people if I do not provide a custom mock resolver. We can generate as many number of people as we like by writing a mock for type list_of_people
I would like to generate the data for 20 or 30 objects instead of the default 2 but I don't want to write a mock for every query which returns a list.
So, I am wondering whether is it possible with this tool to directly mock the generic type Array and have it return 30 instances of type T for all types T instead of writing mocks for every type?
If it is not possible or impractical with it, how can I go about implementing it myself without writing a mock for every type?
Beta Was this translation helpful? Give feedback.
All reactions