Hide menu

An Introduction To GraphQL

Half-day Tutorial at ISWC 2019, October 27, 2019

Presented by Olaf Hartig (Linköping University) and Ruben Taelman (Ghent University -- imec)

Abstract

The GraphQL framework offers a query-based Web interface over a graph-based data structure that may be composed of various types of underlying data sources. GraphQL is highly popular among Web developers, and a lot of developer-friendly tooling is available. While there are several similarities to related techniques used in the Semantic Web context, the actual relationships are not yet well explored. In order to uncover the potential of GraphQL for the Semantic Web community and vice versa, we offer a tutorial in which we introduce GraphQL. The tutorial gives a detailed overview of the different concepts and techniques within the GraphQL framework; the tutorial also contains an introductory hands-on part focused on writing queries in the GraphQL language and interacting with its data model. As a result, attendees will obtain a basic set of knowledge and skills that will allow them to apply GraphQL and to do research related to GraphQL.



Description

This half-day tutorial is structured as outlined below. The tutorial consists of two sessions, where the focus of the first session is on the various concepts of the GraphQL approach and the second session focuses primarily on different aspects of how GraphQL can be used in practice (for more details on these sessions and their content we refer to Table of Contents below). Both of these sessions consist mostly of lecture-style presentations that contain parts in which relevant concepts are introduced, parts in which an understanding of the concepts is reinforced by a discussion of examples, and parts in which specific aspects of the usage of GraphQL are illustrated in terms of short demonstrations by the presenters. In addition to the lecture-style presentations, there is a small hands-on session in which the attendees can get some experience in writing GraphQL queries themselves. Furthermore, we set aside some time at the end of the tutorial for attendees and presenters to engage in a discussion about what GraphQL may mean for the Semantic Web and vice versa.

The overall learning outcome will be an in-depth understanding of the GraphQL approach and the related ecosystem. More specifically, after the tutorial, the attendees will be able to explain the GraphQL approach in general, to read and write GraphQL schemas, and to write GraphQL queries. Additionally, the attendees will be aware of different options---and the respective pros and cons---of how to create GraphQL clients and how to develop and set up GraphQL interfaces (including the existing options to provide GraphQL-based access to an RDF dataset), and they will have a basic understanding of new trends in the GraphQL community (e.g., schema delegation and schema stitching) and of the fundamental properties of the GraphQL query language.



Content

  • Introduction. This part starts with a motivation for GraphQL and for the tutorial, followed by a general overview of the GraphQL approach as a whole, and an outline of the rest of the tutorial.
  • GraphQL Schemas and the GraphQL Query Language. This part provides a detailed introduction to GraphQL schemas and to the GraphQL query language. That is, topics covered in this part are: the different features of GraphQL schemas, the GraphQL schema language, the features of GraphQL queries and of update statements (which are called mutations in the GraphQL context). Since there are direct relationships between the different types of elements of GraphQL schemas and their usage in GraphQL queries, we introduce the features of schemas and the query language together (i.e., alternating between the two).
  • Hands-on. During this part, attendees get a chance to write a few GraphQL queries themselves. For this part, we create a simple GraphQL schema for an interesting dataset (t.b.d.), set up a corresponding GraphQL server with a user interface in which GraphQL queries can be written and executed, and develop a number of exercises that the attendees may solve (i.e., textual descriptions of data retrieval requests that can be expressed as GraphQL queries).
  • Fundamental Properties of the GraphQL Query Language. This part provides an overview of the results of a formal analysis of the GraphQL query language. More specifically, we begin with introducing a normal form of queries that has not only been the basis of the formal analysis, but that also is practical from an efficiency perspective; we highlight complexity results regarding the evaluation problem and the enumeration problem of GraphQL; we discuss the issue of exponential result size blow-up of queries and present an algorithm to address this issue.
  • Emerging Trends. In this last part before the break, we give a brief overview of new techniques that are emerging in the GraphQL community such as the topics of schema delegation (which is a technique for delegating parts of queries to another GraphQL interface) and schema stitching (which is a method for combining multiple GraphQL interfaces into a one).
  • break
  • Client-side GraphQL. This part provides an introduction on how clients can interact with GraphQL APIs, to consume or modify data in applications. We start by explaining how GraphQL interfaces can be queried manually using HTTP requests. Thereafter, we build our way upwards by introducing several low-level libraries (e.g., graphql.js), and more higher-level libraries (e.g., Apollo Client, GatsbyJS) which abstract away most of the common low-level coding tasks.
  • Setting up a GraphQL Interface. In this part, we give an overview of different approaches for setting up GraphQL interfaces. Concretely, we discuss fully-featured tools such as Apollo Server and GraphQL Yoga, but also lower-level libraries such as express-graphql, that can be plugged in as middleware. We discuss their strengths and weaknesses, and provide examples on how they can be used.
  • GraphQL over RDF. In this part, we discuss existing approaches to provide GraphQL-based access to RDF datasets. In particular, we introduce both server-side tools (TopBraid, Stardog, HyperGraphQL) and client-side libraries (GraphQL-LD), and compare their pros and cons.
  • Discussion: GraphQL and the Semantic Web. The final part of this tutorial is an open discussion with the audience, where the importance and relevance of GraphQL from a Semantic Web perspective is discussed. We tackle topics such as the difference in availability of developer tools in these two domains, the problems of non-universal semantics in GraphQL, or any other topics that are suggested by the attendees.


Audience

This tutorial is designed for members of the Semantic Web community who have very basic to no knowledge of GraphQL, but are interested in its concepts and applications. We assume, however, that attendees have at least a basic understanding of Web technologies (HTTP, primarily) and related programming languages (JavaScript). Attendees who want to participate in the hands-on session are expected to bring a laptop that has a recent Web browser.



Presenters

Olaf Hartig is an Associate Professor in Computer Science at Linköping University, Sweden. His research interests are in problems related to the management of data and databases, where his focus in this broad context is on data on the Web and graph data, as well as on problems in which the data is distributed over multiple autonomous and/or heterogeneous sources. In addition to having plenty of experience in teaching university courses, Olaf also has prepared and delivered several tutorials in top conferences such as WWW (2010, 2013, 2017), ISWC (2008, 2009, 2017), and ICDE (2014). Regarding the tutorial topic, Olaf is one of the two authors of the first scientific work on GraphQL which focused on the semantics and the complexity of the GraphQL query language. Additionally, Olaf has been supervising several student thesis projects on different aspects of GraphQL that are planned to become the basis of further publications, and he has discussed his GraphQL-related research with the GraphQL community as an invited speaker at the GraphQL Europe 2018 conference.

Ruben Taelman is a finishing PhD student from Ghent University, Belgium, who is active in the research domain of querying Linked Data. Furthermore, he is investigating the links between GraphQL queries and the RDF data model. Ruben has experience as a tutorial presenter, and assists practical sessions of the Web Development course that is led by Ruben Verborgh at Ghent University.




Page responsible: Olaf Hartig
Last updated: 2019-10-27