Compare clients
Compare features, browser bundle size, and cold-start import cost with graphql-request
Compare the API capabilities, browser bundle sizes, and first-import times of createGraphQLRequest and GraphQLClient from graphql-request.
To switch clients, see From graphql-request.
- Full browser bundle. 72% smaller with gzip and 71% smaller with Brotli.
- Extra bytes with gql.tada. 88% smaller with both gzip and Brotli.
- Cold import. 86% lower median import time in Node.js.
We also measured request throughput with stubbed Fetch and a local HTTP server. We omitted those results because the absolute timing differences were small and the tests did not capture the network latency or server processing of a remote API.
Features
| Capability | createGraphQLRequest | GraphQLClient |
|---|---|---|
| Infer result and variable types | ||
| Read partial data and errors | ||
| Error policy per call | ||
| Operation name inference | ||
| Custom Fetch transport | ||
| Request and response middleware | ||
| GraphQL over GET | ||
| Batch requests | Unavailable | |
| Works without the graphql peer dependency |
See Configure requests and the graphql-request documentation for examples.
Browser bundle size
With gzip, the full browser bundle measured 3.54 KB for createGraphQLRequest and 12.61 KB for GraphQLClient, including each client’s dependencies.
The second comparison shows how many bytes each client adds to a bundle that already exports graphql from gql.tada.
- createGraphQLRequest3.54 KB
- GraphQLClient12.61 KB
- createGraphQLRequest1.39 KB
- GraphQLClient12.07 KB
Cold-start import cost
The median first import took 0.60 ms for createGraphQLRequest and 4.25 ms for GraphQLClient. This time contributes to a serverless cold start when the function imports the client during initialization.
- createGraphQLRequest0.60 ms
- GraphQLClient4.25 ms