@inContext directive doesn't return the translated resource

Hi there,

I’m trying to retrieve a translated shop metafield using the @inContext directive but it always return the default (not translated) value.

This is my query:

  query shopQuery @inContext(language: IT) {
    shop {
      metafield(namespace: "$app:forms", key: "account"){
        id
        namespace
        key
        value
        jsonValue
      }
    }
  }

I expect it to return the metafield translated in italian since the translatable resource is present.

This is the translatable resource:

This is what I get on the extension when calling the query above:

1 Like

Hi @baggio_giacomo

Are you running the query with incontext in a checkout UI extension? Or are you also not seeing the Italian value when you run the query outside of a checkout UI extension (eg just in graphiql)?

Hi @Liam-Shopify,

I’m running the query on a customer account ui extension.

Or are you also not seeing the Italian value when you run the query outside of a checkout UI extension (eg just in graphiql)?

What do you mean? I’m able to get the translatable resource from the graphiql (screenshot above)

Do I have to call directly the customer account ui API?

Hey - from digging into this, it doesn’t look like the @inContext directive works for the Admin API (although it’s supported on the Storefront API). Our team have identified as a limitation on our side and will investigate how this could be supported.

it doesn’t look like the @inContext directive works for the Admin API

Yeah, that’s why I wasn’t understanding how should I test it using the graphiQL app :sweat_smile:

Btw the problem is still there, the @inContext directive is not translating the shop metafield correctly on the customer account ui extension even if the metafield is correctly translated (the translatable resource exist)

Are you using @inContext via the Storefront API? If not - it won’t work.

No, I’m using the Customer Account API on the customer account UI extension

In that case @inContext will have no effect. Our team are aware of this limitation and are evaluating adding support for @inContext to be used with checkout extensions.

Oh okay, so I think it is better to remove the directives section on the Customer account API here :sweat_smile: