GraphQL syntax to request properties by language

19 views
Skip to first unread message

AdrianP

unread,
Jan 10, 2023, 10:34:06 AM1/10/23
to TopBraid Suite Users
Hello...

I'm struggling to find the right GraphQL syntax to request strings specified by localization using the "@en-US" or "@es-US" convention in EDG.

The 'source code' for the data looks like this:

  skos:broader concept_data:VL_00001 ;
  skos:inScheme concept_data:Some_Scheme ;
  skos:prefLabel "A House"@en-US ;
  skos:prefLabel "Una Casa"@es-US ;
 
When I request the data like this:

{
  collectionName(uri: "http://metadata.somecorp.org/concept/concept_data#G_1045") {
    label
  }
}

I get the en-US label:

{
  "data": {
    "collectionName": [
      {
        "label": "A House"
      }
    ]
  }
}

But I need to request the es-US label also.  

Is there a syntax convention I'm missing?

Thank you,

Adrian.

Holger Knublauch

unread,
Jan 10, 2023, 10:55:59 AM1/10/23
to topbrai...@googlegroups.com
The built-in property "label" will always have exactly one value, which is the "most suitable" display label for the surrounding resource.

To fetch specific labels, you need to query prefLabel directly, e.g.

{
  concepts {
    prefLabel {
      string
      lang
    }
  }
}

To return only the en-US labels, use something like

{
  concepts {
    prefLabel(lang:"en-US") {
      string
      lang
    }
  }
}

HTH
Holger


--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/fc002b6d-7764-44c2-92d1-ac6c6202aa9dn%40googlegroups.com.

AdrianP

unread,
Jan 11, 2023, 10:19:33 AM1/11/23
to TopBraid Suite Users
Thank you for the quick response, Holger.  That did the trick.

Adrian.

Reply all
Reply to author
Forward
0 new messages