Skip to content
pubscout

graphql

5.2.4, released 8 months ago by zino.company

A Dart GraphQL client offering queries, mutations, subscriptions and cache management.

WASM-ready
$ flutter pub add graphql
Source repository

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.

  • dio

    Offers advanced HTTP features and interceptors, useful for basic GraphQL over HTTP

Works with

Packages commonly used together with graphql: ones it builds on, ones built on it, and its own family.