Operation Mocks #190
Replies: 12 comments
-
I came here to post this exact same issue. A while back I discovered this plugin and decided to undertake the work to add support for such a feature as a proof of concept for my team, but it was a bit hacked together and I was unsure if doing the work to clean it up and contribute it back here would be in line with the repo's goals. If the maintainer expresses interest, I would happily put in that cleanup work and open a PR. |
Beta Was this translation helpful? Give feedback.
-
Yes it's a current limitation of the plugin to only generate mocks from schema types. If you want to contribute to the project, feel free to add a draft PR so we can discuss the approach! |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
This would be great! |
Beta Was this translation helpful? Give feedback.
-
@foilstormcrow it's going to be awesome contribution. Would it also work with mocking for fragments? |
Beta Was this translation helpful? Give feedback.
-
if you'd like to make a branch, i'm happy to help clean it up! |
Beta Was this translation helpful? Give feedback.
-
Thanks @shaun-sweet feel free to contribute, it will be appreciated! Then we'll be able to bring operation mocks. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
Came here to post the same thing - Following! |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello 👋,
First of all, I would like to say thank you for writing and open-sourcing such an amazing plugin; I am so glad to have come across this library, because in our organization we are finding that writing hand-crafted mocks for tests is neither scalable nor very developer-friendly for developers who are less experienced with GraphQL/Apollo.
Our goal in using this library was to write mocked responses for our components that fetch data from the server, such that those mocks could be fed to the
MockedProvider
component from the"@apollo/client/testing"
package. Unfortunately, we came across what we think might be a limitation, but we would love more guidance and/or insight from you!This is best demonstrated using an example, so please consider the following sample GraphQL schema.
From this, the mock builder of course generates a function called
aTask
(by default), which returns a value of typeTask
. So far, all is well. However, consider our GraphQL operation in our hypothetical component:Now, when trying to generate a mock for this operation using the mock builder generated by this library, we get a Typescript error:
Is there a reason that this mock builder library operates on schema types rather than operation types? Is that a technical limitation or is that simply not the intent of this package? Would you happen to know if another library works off the operation types?
Thanks so much for your help!
Beta Was this translation helpful? Give feedback.
All reactions