Query relationhips that intersect

Hi,

I have three custom types : zones, brands and products. The product type has a relationship to a zone, and to a brand.

How can I retrieve a list of all zones where at least one product is related to the zone and related to brand X ? Also, retrieve all brands for which at least one product is related to this brand and related to zone X ?

I can use graphQL or the SDK or anything else. We are using PHP

Thank you.

1 Like

Hi @ludovic!!

You could do it in different ways. Something that comes to mind is:

  1. Add Content relationships fields, not only to ‘Products’, but also to ‘Zones’ and also to ‘Brands’.
  2. Reference each other. If Product 1 references Zone 4 then Zone 4 also needs to reference Product 1.
  3. Then create a GraphQL query where you call the three Custom types and only call their Content relationships fields respectively.

Hi,

Thank you for your answer, unfortunately it is not possible to add relationships to brands because there are like 10k products and it seems that a relationship field can only link to one document. There are of course many products for one pair of zone/brand.

Could you show me an example of GraphQL query where I can intersect zones or brands with the products for a given brand / zone ?

Thank you