6

TLDR: What's wrong with this GraphQL query? Note that the ... on BinaryComponent isn't rendered although the ... on Component confirms these are multimedia items being returned?

{
  items(filter: {itemTypes: [COMPONENT], 
    #keyword: {categoryId:9195, key: "valueThatExists"}
    customMeta: {key: "clientViews", value: "valueThatExists"}}) {
    #noting we are using the metadata XML name here and not the keyword XML name
    edges {
      node {
        ... on BinaryComponent {
          #nothing picked up here?
          title_fromBINARY:title
          variants {
            edges {
              node {
                variantId
                binaryId_fromBINARY:binaryId
                downloadUrl
                description
              }
            }
          }
        }

        ... on Component {
          itemId_fromCOMPONENT:itemId
          multiMedia
          schemaId #this validates  these are binaries and tagged but how do we drilldown to the download url?
          taxonomies {
            key
            title
          }
        }
      }
    }
  }
}

We have a taxonomy where we have a category with keywords representing clients and sub-keywords under those representing a specific view of the business.

Category ClientViews [categoryId: 9195]
 - Client 1
   - view 1_1
   - view 1_2
 - Client 2
   - view 2_1
   - view 2_2
 - Client 3
   - view 3_1

We then tag MM assets with the client View (these sub-keywords are unique to each client).

Using GraphQL we want to get a list of the views under a specific client (so we can present these as, say, sections) and then within the view list all the relevant PDFs (eventually we'll include other filtering attributes also).

We are trying to use GraphQL to get a list of all MM items that are attributed with (amongst a couple of other attributes) the specific view.

I can get a list of views for a specific client using something like this:

 specificClientViews: keyword(namespaceId: 1, publicationId: 925, categoryId: 9195, keywordId: 91098)
  {
    name, itemId, key, hasChildren
    children {
      edges{
        node {
          title, itemId, key
        }
      }
    }
  }

And this returns the views as expected and then I suppose I can iterate through the views and request the associated PDFs (of course - wrapping these up into as a single PCA response would be great but not sure we can do that without new graphql schemas etc.).

side question: is there a better way to achieve this same aim without having to rely on the IDs?

So we get to the main question as above. Using the query I've put above, why do we not detect the BinaryComponent; the ... on Component section is hit/rendered but the ... on BinaryComponent isn't.

I've only seen ... on BinaryComponent used when the query is specifically a Component{} and had hoped that this would be usable here; is there a better way to achieve this?

Also - I am able to run a query to get components and display the custom meta and taxonomy details so it's all published and in place.

2
4

Not sure if this is helpful, but one way I've retrieved binaries is by first retrieving an "untyped" component (i.e. templateless publishing), and then using the result to find and retrieve any binaries. The second query for binary(ies) should give a URL where the image can be retrieved:

query GetUntypedContent
{
  component(namespaceId: 1, publicationId: 7, componentId: 906) {
    content {
      ... on UntypedContent {
        data
      }
    }
  }
}

query
{
binaryComponent(namespaceId:1, publicationId:7, binaryId:905) {
  id
  variants {
    edges {
      node {
        id
        downloadUrl
      }
    }
  }
}
}
1
  • Thanks Damian - we've tried with the rawdata and validated it does work - however, (1) the fundamental question is why is the fact it's ,,,on BinaryComponent not detected and (2) the roundtripping is something we need to avoid. If the query itself looks good and it seems it should be supported so maybe we'll reach out to Tridion Support. Aug 31 at 9:04
2

This is a defect. R&D are working on a fix, at this point I'm waiting for confirmation on what timeline I have and will update the note here with the hotfix number.

The only alternative I see at the moment is to iterate through the items returned and make an individual request for each binary item download URL. At up to 1000 a page that's not going to be pretty but at least I can confirm my functionality - if not the UX!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.