AD Research Wiki
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

FrontPage

Revision 4 as of 2020-10-05 14:06:44
AD Research Wiki:
  • Projects
  • GraphQL

Contents

  1. What is GraphQL?
  2. Example
  3. GraphiQL

What is GraphQL?

GraphQL ("Graph Query Language") is a specification for a query language that was created by Facebook in 2012 for internal use and publicly open sourced in 2015. It is specifically focused on API development ("A query language for your API") and serves as an alternative to REST-based architectures.

Since GraphQL is a specification, the user can decide between various implementations in different programming languages, almost all of which use JSON to access data. You can find a list containing some of the most popular libraries and services here.

GraphQL is not tied to a specific schema or structure of the database. It is much less powerful than other query languages and not designed for exploiting the rich semantics of expressive ontologies.

Clients specify the data they need, receiving only what they ask for and nothing more. Thus, it minimizes the amount of data transferred and is particularly useful for mobile apps and websites.

GraphQL serves as a framework for defining your own query language on JSON-like data. GraphQL allows users to define the shape (the "schema") of data that they want to be accessible. This schema defines the semantics and the structure of the queries that are allowed.

Example

Queries in GraphQL are like JSON data without the values. For example:

{
  chair {
    name
    lectures {
      name
      language
    }
  }
}

This query might return something like

{
  "chair": {
    "name": "Chair of algorithms and data structures"
    "lectures": [
      {
        "name": "Programmieren in C++"
        "language": "German"
      }
      {
        "name": "Information Retrieval"
        "language": "English"
      }
      {
        "name": "Algorithmen und Datenstrukturen"
        "language": "German"
      }
    ]
  }
}

TODO: Explain more how queries work and how the schema is defined.

GraphiQL

The GraphQL foundation also provides "GraphiQL", a graphical interactive in-browser GraphQL IDE for editing and testing queries. GraphiQL offers syntax highlighting, autocompletion, a documentation explorer, query history and other features. Again, there are libraries in various languages to choose from.

TODO: Set up a docker container that build a GraphiQL example to play around with.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01