Skip to content
TU Dresden
A joint project with Uni Leipzig DE EN

Querying Wikidata with GraphQL

A talk by Anas Shahab:
June 8, 2023
11 a.m. – noon
TU Dresden, APB/3027 | BigBlueButton
Join us now: https://bbb.tu-dresden.de/b/pio-zwt-smp-aus
https://iccl.inf.tu-dresden.de/web/Querying_Wikidata_with_GraphQL/en

Abstract

Knowledge graphs like Wikidata are widely used in commercial and research domains. They represent knowledge that conveys information about the real world in the form of graphs. Often they are modelled using directed-edge labelled graphs using the Resource Description Framework (RDF). RDF is a framework that represents information in the form of Linked Data. SPARQL is a protocol and query language for RDF. It is based on matching graph patterns and is used to query RDF graphs. SPARQL is a powerful query language as it is expressive, and provides many features to retrieve and manipulate data. However, SPARQL queries are complex in nature and have a steep learning curve. There are few tools and libraries available to developers for working with SPARQL. GraphQL is a popular query language for working with APIs. It is a flexible query language and is designed to have a human-oriented syntax. This makes it easy for developers to learn and implement it in applications. Moreover, there are many supporting resources that help the integration of GraphQL into the development of such systems.

The purpose of our work is to show ways of querying the knowledge graph, Wikidata, using GraphQL queries. This helps avoid the complexity of dealing with SPARQL queries, and makes use of the flexibility and features offered by GraphQL. In this work, we show some key differences between GraphQL and SPARQL. We show some existing commercial and open-source solutions to query RDF data via GraphQL. Our main focus is to introduce two existing open-source solutions, GraphQL-LD and HyperGraphQL, that can be used to query Wikidata via GraphQL queries. Both these approaches use GraphQL queries to act as layer of abstraction that hides the complexity of SPARQL queries. We show extensively how these approaches operate and the respective features that they offer. We provide details on how we can use GraphQL-LD and HyperGraphQL to fetch data from Wikidata and demonstrate the results. Since they are open-source, we made appropriate changes to the source code to implement the approaches on Wikidata. The changes were also made to help analyse the steps in the implementation and facilitate querying. Our results show that some key differences between GraphQL-LD and HyperGraphQL exist in terms of implementation and features. We demonstrate these in this work extensively and compare them via examples against standard GraphQL and SPARQL features.