You don’t need a fancy framework to use GraphQL with React

All you need is a good naming strategy

Samer Buna
Published in
12 min readMar 14, 2017

--

React offers a great language to declaratively describe User Interfaces (web or otherwise) and GraphQL offers a great language to declaratively describe data requirements. React gives us composability with its components and GraphQL gives us composability with its fragments. These two similarities allow for a great match between React and GraphQL (a match made in Facebook).

In this article, I’ll walk you through a simple example to connect a blog app written in React with a GraphQL API without using any frameworks like Relay or Apollo.

Those frameworks exist for very good reasons. Here are a few generic things such frameworks try to do (not a complete list):

  • Performance. For example, batching multiple network requests into one and displaying a big list of records without overwhelming the app memory through the use of pagination.
  • Efficiency. For example, asking servers for only the new data required and then merging new data with old data, or asking servers for only the data used in the visible window and asking for the rest of the data after that.
  • Dealing with failure. For example, employing a standard error handling for failing requests and a standard…

--

--

EdgeCoders
EdgeCoders

Published in EdgeCoders

jsComplete’s Medium Publication — jsComplete is a FREE software educational library focused on JavaScript, Node, React & GraphQL. It has video courses, books, articles, and interactive lessons.

Samer Buna
Samer Buna

Written by Samer Buna

Author for Pluralsight, O'Reilly, Manning, and LinkedIn Learning. Curator of jsComplete.com

Responses (7)