New package graphql: A GraphQL Query Parser

October 5, 2016

(This article was first published on rOpenSci Blog - R, and kindly contributed to R-bloggers)

The new ropensci graphql package is now on CRAN. It implements R bindings to the libgraphqlparser C++ library to parse GraphQL syntax and export the syntax tree in JSON format:

graphql2json("{ field(complex: { a: { b: [ $var ] } }) }")

A syntax parser is perhaps not super useful to most end-users, but can be used to validate graphql queries or implement a GraphQL API in R. We hope to add more related functionality later on.

What is GraphQL

From the GraphQL website:

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

GraphQL is a new approach and syntax to structuring API queries. It provides a modern, and perhaps more natural alternative to e.g. REST or SQL (which were designed for hypertext and relational data, respectively). A GraphQL query on the other hand resembles the structure of the data. For example the query:

  me {

Could produce the JSON result:

  "me": {
    "name": "Luke Skywalker"

The Github API supports GraphQL and illustrates how GraphQL reduces the number of requests and data in comparison with traditional REST queries.

To leave a comment for the author, please follow the link and comment on their blog: rOpenSci Blog - R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)