-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
MockLink: add query default variables if not specified in mock request #11806
Conversation
🦋 Changeset detectedLatest commit: e9d26e5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thinking out loud for a minute here. I actually kinda like the existing behavior purely for its explicitness. Take the following: query GetTodo($id: ID = 1) {
# ...
} and the following mocks: const mocks = [
{
request: { query, variables: { id: 1 } }
},
{
request: { query }
}
] Would you be aware that these are equivalent in the context of this query? On the flipside, I totally understand the confusion on this. I guess it depends on what end of the spectrum you look at this. If you're thinking about it so that Thoughts? At the very least, just wanted to start a discussion on this to see what we think. |
I think the important part here is the "in the context of this query" - in the context of this query, they could either be identical (this PR) or the second mock would be "impossible to reach" (current behaviour). We could also think about warning about "impossible mocks", like
I'm not sure I like that too much, it seems like forcing an additional step on the user (and possible confusing them) for no good reason. |
I would agree, I'm not super fond of it either. Anyways, I think the pros outweigh the cons I mentioned, so I'm good with this one. Just wanted to have the conversation to make sure we at least discussed it. Thanks! |
Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
@phryneas is this something we can get in 3.11? |
Good point - on it! |
resolves #8023
This would resolve an old feature request and make it unnecessary to specify variables that match a mock query's default values.
Not sure if this counts as a patch or a minor though, and it will definitely not make it in 3.10.0, so I'm just opening it against
main
and we can discuss that separately.