Is there a chance for a `any` matcher? E.g. ```rel...
# pact-js
v
Is there a chance for a
any
matcher? E.g.
Copy code
relationships: any({}),
so that it could be any object with attributes
1
y
I can imagine this opens up a huge can of worms I wonder if this may fall into the camp of why there is no support for specify optional attributes https://docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes If that didn't apply, if you said it was any object, how would a provider validate/match against any object, would they just provide any object back?
If you have an example of the particular use case, that would be great!
b
It feels like if your consumer doesn't care what relationships is then it's not actually using it and therefore shouldn't be in the contract
💯 1
Pact is not meant to be a general API validation framework
v
It’s an issue we are aware of. It’s just that until we migrate away from over-fetching it’d be nice to ignore some attributes
b
But just because you fetch a property doesn't mean you use it. The question to ask is "if the API never returned this property, what would happen to my consumer?" If the answer is "nothing", you don't need it
☝️ 2
👌 2
v
Use case would be that a certain part of the payload has been masked. I am still retrieving a lot from the payload, but I’m most interested in a specific section
b
If the answer is "well it crashes, or can't perform some expected function" you probably do
v
To be clear, I’m not arguing for having the attribute in. It’s just that until I migrate away from the overfetching/attribution (since a lot of other consumers use this 1 massive endpoint). I’d like to keep it in
b
Are you the provider maintainer?
v
I am for now.
b
And you're writing the consumer contracts?
v
Until we split out the teams yes
m
Another option is to consider something like Pactflow’s BDCT feature. This might be more appropriate for a provider-driven approach
b
To be clear, I’m not arguing for having the attribute in. It’s just that until I migrate away from the overfetching/attribution [...] I’d like to keep it in
Basically, if you don't need the attribute, you can leave it out. If you need something in its children, put it in. You don't have to specify all of the child attributes either, just the ones that are load-bearing 🙂