Expand taxonomy/tags in the GraphQL API response for Headless Channels

In the GraphQL API response of a headless channel, I am looking to be able to see the hierarchy of a tag within the taxonomy module. Has anyone seen how this can be achieved?

For example, in the Taxonomies module I have:

In the API response, it might look something like this:

You can only see the name/codename of the tag, but not the hierarchy of it (e.g. from the taxonomy module, it would be nice to see it's under "Guests").

I have logged this as a request to the roadmap, to see if it can be added as a feature, maybe adding a path like KX13 used to do with the codenames? e.g. Guests/2Guests for this scenario.

Tags:
Taxonomies Headless channels GraphQL
0

Answers

I agree Liam, a (KX13 style) path property would be a nice addition.

Alternatively, a new children property, containing a list of child tags would be another way to go.

0

I don't think headless channels are at all extensible today (v31.0.0).

If you need additional taxonomy data, you can create a custom API endpoint that responds with a hierarchy path and send it the tag code name from the headless channel response or expose the taxonomy tree over an endpoint to get that hierarchy information.

For now, because headless channels are really designed for marketers to have control over what content is exposed, you might need additional endpoints for related data.

0

Or, at least expose the ParentID property in GraphQL. It is already in the DB and using it, doing some bit more coding, you could get the "tree structure".

0

Yeah I think until the headless API is expanded to support the tag/taxonomy relationships, I think we'll have to unfortunately make a custom REST API or something to offer the structure to receiving platform.

I've already tried expanding the Tag model returned from the GraphQL API using HotChocolate's ExtendObjectType but this doesn't seem to be picked up by the system.

builder.Services
    .AddGraphQLServer()
    .AddTypeExtension<TagExtensions>();
[ExtendObjectType("_Tag")]
public class TagExtensions
{
    /// <summary>
    /// Gets the tag codename with a "test-" prefix
    /// </summary>
    [GraphQLDescription("Tag codename with 'test-' prefix")]
    public string GetPrefixedCodename([Parent] Kentico.Xperience.Headless.Internal.Tag tag)
    {
        return $"test-{tag.Name}";
    }
}
0

To response this discussion, you have to login first.