Feature | GraphQL | REST |
---|---|---|
Flexibility | 👍 Client specify exact resource & fields in GraphQL schema (query param), it wants. | Rigid |
Speed | 👍 GraphQL is faster than REST because as you can pick the fields you want to query, so the request will always be the smallest possible. | |
Prerequisites/Overheads | 👎 Extra-tools are needed on both client & server side. | 👍 Standard CURL is supported. No extra tools needed. |
HTTP Cache (Browsers, CDNs, Proxy Servers) | 👎 Not-Supported | 👍 Supported |
Security | 👎 Un-required table scan can be done, by client. This can be mitigated, but with maintenance overhead. | 👍 Good. |
Over-fetching | No | Yes |
Both REST and GraphQL are based on following,
- HTTP
- API URL
- Can return JSON response