How to use
@prismicio/client and predicate all Partners (custom type) that contains (slices) one or more category (another custom type)?
How to use
Welcome to the Prismic community, and thanks for reaching out to us.
Could you please tell me what version of
@prismicio/client you are using?
@prismicio/client is primarily responsible for handling requests to your Prismic endpoint. Here is a technical reference about
@prismicio/client. You can check the different versions in the given link.
With version @prismicio/client 5, To get all documents of a particular type, you'd use the
at predicate to search for all documents where the "type" matches a given value.
To fetch a specific content field from a linked document. You need to use fetchLinks or graphQuery options.
Could you please tell me more about your use case so I can provide you more precise answer?
but how to get all custom_type that contains specific custom_type inside. In my case, I have Partner (this is a custom_type) and I have Category (this is also custom_type). In Partner there are slices of Categories; I want to get all Partners that contains Category A, how to do it?
To retrieve content from linked documents and content relationships within a Slice of a specific Custom Type, you need to use the deep fetching method graphQuery.
In that case, you need to specify the Content Relationship field in your GraphQuery. Here is the documentation for this .
I assumed your content relationship field inside a Slice in a non-repeat zone. Please change the code if your field is inside a repeatable zone by following the documentation link I shared above with you.
Let me know if you have further questions related to it.
What you're searching for is the query by content relationship predicate which is documented here:
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.