graphql
5.2.4, released 8 months ago by zino.company
A Dart GraphQL client offering queries, mutations, subscriptions and cache management.
WASM-ready
What it does
Provides a GraphQLClient to send queries, mutations and subscriptions to any GraphQL server. Includes built‑in caching, persistence via HiveStore and link composition for authentication and websockets.
AI-written summary of version 5.2.4, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a full‑featured GraphQL client in a pure Dart/Flutter app
- You want built‑in caching, persistence and link system for auth or websockets
Skip it when
- You only need simple HTTP GET/POST without GraphQL features
- You prefer a code‑gen based client like graphql_flutter's generated types
Strengths
- Rich feature set: caching, persistence, link composition
- Supports queries, mutations, subscriptions and custom links
- Works on all Flutter platforms
Weaknesses
- Setup can be verbose compared to plain HTTP calls
- No built‑in code generation; you must handle types manually
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 17
Add graphql to pubspec, optionally add hive/hive_ce for persistence, initialize HiveStore if using cache persistence
import 'package:graphql/client.dart';
final httpLink = HttpLink('https://api.github.com/graphql');
final authLink = AuthLink(getToken: () async => 'Bearer YOUR_TOKEN');
final link = authLink.concat(httpLink);
final client = GraphQLClient(cache: GraphQLCache(), link: link);
final query = gql(r'''query { viewer { login } }''');
final result = await client.query(QueryOptions(document: query));
print(result.data);Alternatives
Packages that do the same job and could replace graphql.
Works with
Packages commonly used together with graphql: ones it builds on, ones built on it, and its own family.
- uuidgraphql depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- web_socket_channelgraphql depends on itCross‑platform WebSocket channel wrapper for Dart
- stream_channelgraphql depends on itAn abstraction for two-way communication channels based on the Dart Stream class.
- rxdartgraphql depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- hive_cegraphql depends on itA lightweight and fast NoSQL key-value database written in pure Dart.
- gql_http_linkgraphql depends on itHTTP link for executing GraphQL requests via JSON.
- gqlgraphql depends on itParse, transform and print GraphQL documents in Dart.
- normalizegraphql depends on itNormalizes and denormalizes GraphQL responses to a cache-friendly map structure.