Query content relationship in multiple document types feature

After following the Prismic user guide on how to model content relationships with custom tags (Create a custom tagging system - FAQs - Prismic People) I'm left disappointed that you end up with a very rigid tagging system.

As mentioned in this topic Query content relationship in multiple document types Prismic API only supports querying one custom type relationship. AKA I cannot query custom types: A, B, C, that all have a shared content relationship field with an API name of 'tag' in one query.

The solution suggested in the topic is to stitch the results together after doing multiple queries for said types. However, this does not consider pagination and sorting functionality that is lost by doing this, which is a basic need of most blogging sites.

Will the Prismic team be resolving this short coming any time soon? Especially given native tags won't be returned in the impending breaking change.

1 Like

Hi Alex,

Welcome to the prismic community.

Well, in fact, yes,

If you follow this guide to build a custom tagging system with the ability to query multiple documents from multiple custom types at the same time,

Then you can't have a sorting or pagination out of the box if you initiate multiple queries and stitch the result.

The solution for this limitation would be to paginate the stitched results on your server.

Also we have already a feature request of querying documents from multiple custom types in one query and will update this feature request with your use-case.

But
Prismic is not going to depreciate the tagging system, and this is a common misunderstanding of the deprecating the /API tags in this blog post

So, in fact, you can use the native tags as usual as we are only going to remove the tags from /api

Please let us know if you still have some doughts.
Fares

Thanks for the clarification @Fares this is indeed a misunderstanding that I had shared. So that is good to know for future developments.

To solve my particular use case I resorted to tagging articles twice. Once using custom tagging and once using native, to allow for sorting and pagination direct from the Prismic API.

For me I think the statement:

You will also be able to query any documents linked to a certain tag in your system.

At the end of the custom tagging guide needs some clarification. It eludes to being able to do cross document querying for content relationships, when that is not the case.

Yes I agree this article needs some extra clarification and I will add this to our to do list, but will the native tagging system be a valid solution for your use-case?

Yes, with the slight caveat that the content author will have to tag the document with native and custom tagging.

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.

Is this still not possible?

Is there any way at all to query multiple custom types over a content relationship field?

Hello @prismic28

Welcome to the Prismic community, and thanks for reaching out to us.

You can query one document type by multiple content relationships but not multiple document types by a content relationship.

We have added this as a feature request to the tracker but do not plan to implement this in our current roadmap. We'll update you here if/when we have any changes to this.

For now, the only way to do this will be to make multiple queries.

Let me know if you have any further questions.

Thanks,
Priyanka