rmccue / ama

Ask me anything!
6 stars 1 forks source link

GraphQL and WordPress! #17

Closed ahmadawais closed 6 years ago

ahmadawais commented 7 years ago

What are your thoughts on GraphQL and WordPress? How do you compare it with WP REST API?

rmccue commented 6 years ago

I missed this previously, apologies!

I think GraphQL is a great solution for a few things: I think it's a fantastic API for things backed by a graph database, and I think it's a decent query language for everything else.

That said, I don't think it's a great API generally for when you're not really dealing with a graph. Facebook is built around a graph database, and is fundamentally a graph, so it makes lots of sense. However, most services are built around relational databases with more discrete models instead, so they benefit from using things more suited to that (like SQL).

As an example, something like "query this user and their top 5 friends" is easy with a graph database, because you start with a node and query the edges (plus their corresponding nodes), allowing you to fetch related data really easily. But, the same query for something backed by a relational database could end up with a query with 40+ JOINs, and kill the server.

renatonascalves commented 6 years ago

@rmccue Do you think usage of GraphQL will increase, at a point it will be more used than the REST API?

rmccue commented 6 years ago

@renatonascalves I think they're simply designed for different things, and complement each other. I could see a future where WordPress had a /query API which uses GraphQL, but which is embedded into a REST API.