GraphQL vs Relay
The difference is clear. GraphQL provides a way to model and expose data in your app. You can use it on top of any kind of data source and use it with any kind of transport layer.
On the other hand, Relay is an efficient client-side data-fetching technology built for React. It talks to a GraphQL Schema to get data. Relay also has a server-side part that adds some features on top of GraphQL.
If you haven’t tried GraphQL yet, give it a try with our Learn GraphQL course. You can complete it under 2 hours.
Can I use GraphQL without Relay?
In other words, can I use GraphQL with Angular, Ember, Redux, or even with just React?
Of course! You can simply replace your existing data-fetching code to use GraphQL.
For example, let's say we have a to-do app. We have been using a set of REST APIs to interact with the server. Instead of using REST, let’s use GraphQL over HTTP.
Here are a couple of examples:
Here, I showed you some sample apps using GraphQL. When you use it with a real app, you may need more features, such as caching, optimistic updates, and authentication.
You can definitely use GraphQL with any front-end technology you are using right now. The Relay team is also thinking about separating the GraphQL cache inside Relay. At this time, though, that’s not a high priority.