Continuing our mission at dfuse to bring powerful developer tools to the blockchain, we are thrilled to introduce the strength of GraphQL to EOSIO. It helps to greatly reduce the returned payload when running a query, giving you the ability to pin-point *just* the data you need.
GraphQL was introduced as open source by Facebook in 2015, and has since seen an incredible uptake in adoption among software engineers. It has simplified the lives of many developers, in large part due to it enforcing a defined and shared schema: this provides clear contract boundaries between the developer and the API provider.
GraphQL Queries and Subscriptions
GraphQL Queries are request/response calls, but, unlike REST where you fetch one resource at a time, a GraphQL Query enables you to fetch multiple related pieces of data in a single query. You can read a plethora of comparisons of REST vs GraphQL on the web.
GraphQL Subscriptions enable streaming of messages, usually over a WebSocket, to enable an app to be informed in real-time of anything new. dfuse uses GraphQL Subscriptions to enable you to stream transactions as they occur in real-time, and enables you to navigate any chain reorganization.
Getting Started with GraphQL on dfuse
You can use our GraphiQL playground to test it out. Be sure to take advantage of the built in auto-completion to help with discoverability, as well as the documentation for each field.
Some benefits of using GraphQL:
- Save bandwidth and processing: retrieve only the data you need, avoid clogging pipes and data plans with useless data.
- Combined with the brand new search features in the API, you can use the power of dfuse Search in streaming mode: you can be even more specific as to what you retrieve.
- Strictly defined schemas mean clean documentation, easy discovery, auto-completion, incredible developer tooling and improved development experience.
- For EOS, this means configurable encoding of some fields (like representing a number as an account name, or an asset symbol, or as a hex string, etc.), doing more work in fewer queries.
We have slowly rolled out the GraphQL endpoints to all supported networks. The dfuse GraphQL interface is currently in Beta, and as such we welcome your feedback and comments. We are excited to enable you to do more, with less.