Need advice about which tool to choose?Ask the StackShare community!
GraphQL vs Redux: What are the differences?
What is GraphQL? A data query language and runtime. GraphQL is a data query language and runtime designed and used at Facebook to request and deliver data to mobile and web apps since 2012.
What is Redux? Predictable state container for JavaScript apps. Redux helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger.
GraphQL can be classified as a tool in the "Query Languages" category, while Redux is grouped under "State Management Library".
Some of the features offered by GraphQL are:
- Hierarchical
- Product-centric
- Client-specified queries
On the other hand, Redux provides the following key features:
- Predictable state
- Easy testing
- Works with other view layers besides React
"Schemas defined by the requests made by the user", "Will replace RESTful interfaces" and "The future of API's" are the key factors why developers consider GraphQL; whereas "State is predictable", "Plays well with React and others" and "State stored in a single object tree" are the primary reasons why Redux is favored.
GraphQL and Redux are both open source tools. It seems that Redux with 49.5K GitHub stars and 12.8K forks on GitHub has more adoption than GraphQL with 11.7K GitHub stars and 753 GitHub forks.
According to the StackShare community, Redux has a broader approval, being mentioned in 1036 company stacks & 836 developers stacks; compared to GraphQL, which is listed in 561 company stacks and 750 developer stacks.
Pros of GraphQL
- Schemas defined by the requests made by the user74
- Will replace RESTful interfaces62
- The future of API's60
- The future of databases48
- Self-documenting12
- Get many resources in a single request11
- Query Language5
- Ask for what you need, get exactly that5
- Fetch different resources in one request3
- Evolve your API without versions3
- Type system3
- Easy setup2
- GraphiQL2
- Ease of client creation2
- Good for apps that query at build time. (SSR/Gatsby)1
- Backed by Facebook1
- Easy to learn1
- "Open" document1
- Better versioning1
- Standard1
- 1. Describe your data1
- Fast prototyping1
Pros of Redux
- State is predictable190
- Plays well with React and others149
- State stored in a single object tree125
- Hot reloading out of the box78
- Allows for time travel72
- You can log everything14
- Great tutorial direct from the creator11
- Test without browser6
- Endorsed by the creator of Flux6
- Easy to debug5
- Enforces one-way data flow2
- Granular updates2
- Blabla1
Sign up to add or upvote prosMake informed product decisions
Cons of GraphQL
- Hard to migrate from GraphQL to another technology4
- More code to type.4
- Takes longer to build compared to schemaless.2
- All the pros sound like NFT pitches1
- Works just like any other API at runtime1
Cons of Redux
- Lots of boilerplate11
- Verbose6
- Design5
- Steeper learning curve than RxJs4
- Steeper learning curve than MobX4
- Steep learning curve4