Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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 { name } }
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.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.