Skip to content

Instantly share code, notes, and snippets.

Last active February 26, 2023 21:19
What would you like to do?


GraphQL-LD is a way to query Linked Data using GraphQL.

Instead of querying GraphQL interfaces, Linked Data interfaces are queried, such as SPARQL endpoints, TPF interfaces, Linked Data documents, ... This is done by semantifying GraphQL queries using a JSON-LD context.

Try it out from your browser:

Alternatively, install GraphQL-LD or Comunica SPARQL and execute GraphQL-LD queries on your machine

The basics

In order to execute queries, you'll need to parts:

  1. A GraphQL query: to select data
  2. A JSON-LD context: to map query fields to URIs

With this, GraphQL queries can be translated into a SPARQL query, using which any Linked Data source can be queried.


Find all labels in a dataset

GraphQL query:


JSON-LD context:

  "@context": {
    "label": { "@id": "" }

This query will be translated into the following triple pattern:

_:b <> ?label

More information

If you want more details on how GraphQL-LD works, please refer to our article or our GraphQL-LD tool

Related software

Copy link

➡️ Edit: I'm sorry, i think my example is wrong. Just tried it out, and it doesn't really seem to filter

Hi, is there a filter option available? For example, to filter saying the language of a label to be German?
{ movie { name (lang="de") } }


One possible way may be to specify the language in the @context:

"@context": {
    "label": { "@id": "" },
    "label_de": { "@id": "", "@language": "de" },

and then you'd use it

{ movie { label_de } }

Check out the examples on Comunica website.

I'm completely new to graphql-ld, so there might be other ways, idk... hope this helps, anyways...

It provides a lang tag to an item when that item is passed as an argument. However, it does not work with variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment