https://pact.io logo
#pact-js
Title
# pact-js
v

Victor Lau

04/25/2022, 4:27 PM
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

Yousaf Nabi (pactflow.io)

04/25/2022, 4:48 PM
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

Brendan Donegan

04/25/2022, 8:32 PM
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

Victor Lau

04/25/2022, 8:45 PM
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

Brendan Donegan

04/25/2022, 8:47 PM
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

Victor Lau

04/25/2022, 8:47 PM
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

Brendan Donegan

04/25/2022, 8:48 PM
If the answer is "well it crashes, or can't perform some expected function" you probably do
v

Victor Lau

04/25/2022, 8:48 PM
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

Brendan Donegan

04/25/2022, 8:49 PM
Are you the provider maintainer?
v

Victor Lau

04/25/2022, 8:49 PM
I am for now.
b

Brendan Donegan

04/25/2022, 8:49 PM
And you're writing the consumer contracts?
v

Victor Lau

04/25/2022, 8:50 PM
Until we split out the teams yes
m

Matt (pactflow.io / pact-js / pact-go)

04/25/2022, 11:01 PM
Another option is to consider something like Pactflow’s BDCT feature. This might be more appropriate for a provider-driven approach
b

Boris

04/26/2022, 1:16 AM
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 🙂