[12.x] PendingRequest@withAttributes()
#58054
Merged
+94
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had tried this previously in #57944 but now I have a slightly different reason for needing it. Here we are just passing it to the Request object, and my vision is that we would use this for essentially naming the call.
Why
The company I work for integrates with Shopify's GraphQL API. Every request hits the same endpoint, and as such, writing unit tests with stubbed HTTP responses is no fun, because your best bet is to compare against a string that's in the request... but you sort of have to know what's the most unique string in the GraphQL query. 😿
An example
Instead, it would be great if we could just kind of "name" our requests, like this:
and then inside of the test:
Alternatives
Just create a
requestNamestring property. That definitely fits my use case most narrowly, but also, how soon before someone wants to store something else in there? Though that would be really nice because when calling$pool->as('get_shop'), that could also set the requestName. 🤷