dcporter7
dcporter7

Reputation: 555

What benefit does Graphql provide over JBuilder in Ruby on Rails?

I've been hearing a lot of developers raving about Graphql. After implementing in Ruby on Rails, I've begun to realize that it essentially does the same thing as JBuilder, which is built-in to Rails 5.

From a Rails perspective, what benefit does Graphql provide over JBuilder? Are they essentially used for the same thing? Is there something I'm missing in regards to Graphql?

Upvotes: 0

Views: 285

Answers (1)

Bartosz Sypytkowski
Bartosz Sypytkowski

Reputation: 7542

One of the advantages of GraphQL is the fact, that it's a formally specified standard with its own query language.

It's safely-typed standard with its own specification. This means, you can interop with servers written in different tech stacks using the same query language and type system.

Since it's standardized, a few frontend js libs (Relay and Apollo) have taken advantage of that, making it very easy to cache and define tailored, client-scoped queries and mutations.

It exposes its own structure as so called Introspection API. This means that, you can document your API and query it using GraphQL itself - its self-descriptive. This gives a space for tooling support - example of such is GraphiQL, which allows to explore GraphQL schemas with ease. When using GraphQL, this feature is basically granted for free. You can see it in action i.e. in Github API Explorer, which also uses Ruby implementation of GraphQL AFAIK.

While most people think about it in terms of request/response, it also exposes publish/subscribe capabilities as GraphQL subscriptions via web sockets. Also within a standard.

Upvotes: 2

Related Questions