Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow wildcard/function request for MockLink requests #351

Closed
fabis94 opened this issue Dec 14, 2022 · 2 comments
Closed

Allow wildcard/function request for MockLink requests #351

fabis94 opened this issue Dec 14, 2022 · 2 comments
Labels
project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing

Comments

@fabis94
Copy link

fabis94 commented Dec 14, 2022

As per the docs:

Your test must execute an operation that exactly matches a mock's shape and variables to receive the associated mocked response.

This is not very good DX, it would be better if you could use wildcards for requests or at the very least allow request to be use a predicate function that returns true/false depending on whether the incoming request should return a specific mocked response. It's a fairly common use case to just want to return a mocked query response for any kind of variables.

@dylanwulf
Copy link

I think this issue is already being discussed here: apollographql/apollo-client#9738

@jerelmiller
Copy link
Member

Hey @fabis94 👋

We have merged the ability to dynamically match variables and I believe this will get you what you're looking for with your request.

This feature will be available starting with our next minor release v3.9.0. If you're interested in trying this out, this is available now in prerelease version v3.9.0-alpha.0 or later.

I'm going to go ahead and close this issue as completed. If the variablesMatcher doesn't address your needs, feel free to add a comment and I'll reopen this issue. Thanks for the request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing
Projects
None yet
Development

No branches or pull requests

3 participants