Skip to content
pubscout

graphql_flutter

5.3.0, released 8 months ago by zino.company

A GraphQL client for Flutter with widget wrappers and hooks.

$ flutter pub add graphql_flutter
Source repository

What it does

Provides an idiomatic Flutter API, widgets, and hooks to execute GraphQL queries, mutations, and subscriptions. It supports caching, optimistic UI updates, and pagination out of the box.

AI-written summary of version 5.3.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a Flutter app that communicates with a GraphQL backend.
  • You want declarative Query and Mutation widgets or hooks in your UI.

Skip it when

  • Your backend uses a standard REST API instead of GraphQL.
  • You prefer an extremely lightweight HTTP client without schema caching.

Strengths

  • Comprehensive feature set including caching, pagination, and optimistic mutations.
  • Supports both traditional Flutter widgets and flutter_hooks.
  • Built-in integration for local persistence stores like Hive.

Weaknesses

  • Requires specific Android build configurations (Java 17 and Gradle 8.4).
  • Can add substantial complexity for simple applications.

Setup

Kind
Flutter widgets
Effort
Medium
Code generation
No
Direct dependencies
9

Requires initializing Hive for caching, wrapping your app with GraphQLProvider, and updating Android settings to Java 17 and Gradle 8.4.

ValueNotifier<GraphQLClient> client = ValueNotifier(GraphQLClient(link: link, cache: GraphQLCache(store: HiveStore())));

GraphQLProvider(
  client: client,
  child: MaterialApp(
    home: Query(
      options: QueryOptions(document: gql(readRepositories)),
      builder: (QueryResult result, { VoidCallback? refetch, FetchMore? fetchMore }) {
        if (result.isLoading) return Text('Loading');
        return Text('Loaded');
      },
    ),
  ),
);

Alternatives

Packages that do the same job and could replace graphql_flutter.

  • ferry

    A GraphQL client for Dart and Flutter with code generation and normalized caching.

  • dartssh2

    SSH and SFTP client written in pure Dart

  • ferry_flutter

    Flutter widgets for executing GraphQL operations using the ferry client

  • graphql_codegen

    Generate Dart serializers and client helpers from GraphQL queries and schemas.

Works with

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