datocms / plugins

Repository providing samples using the Plugins SDK
MIT License
33 stars 47 forks source link

Web Previews - Unable to generate more complex url structures #71

Closed evangelinepapanicola closed 2 years ago

evangelinepapanicola commented 2 years ago

Hi! I've got a Model where the Records' urls are based on a "Single link" field (called category) as well as the slug field, so for example I'm trying to do:

    case 'article':
      return `/${item.attributes.category.slug}/all/${item.attributes.slug}`;

Unfortunately, item.attributes.category seems to return the category ID rather than the object, so I can't access the category's slug.

Is there a workaround for this? I can't think of a way to get the article category slug here, other than by performing a GraphQL query in my preview-links endpoint which doesn't feel optimal.

Thanks in advance!

stefanoverna commented 2 years ago

Yes, you need to perform a GraphQL query for this.. or in alternative a call to our Content Management API :/