dartpollo 0.1.0-alpha.1 copy "dartpollo: ^0.1.0-alpha.1" to clipboard
dartpollo: ^0.1.0-alpha.1 copied to clipboard

A Dart GraphQL client with caching support. Build dart types from GraphQL schemas and queries.

dartpollo #

A Dart GraphQL client with built-in caching support. Executes typed GraphQL queries generated by dartpollo_generator.

Features #

  • Typed GraphQL execution — Execute generated query classes and get typed responses
  • Caching — Built-in cache layer with pluggable stores (in-memory, Hive)
  • Cache policies — Control caching behavior per-query (cache-first, network-only, etc.)
  • GQL link support — Built on top of the gql_link ecosystem

Installation #

dependencies:
  dartpollo: ^0.1.0

dev_dependencies:
  build_runner: ^2.10.0
  dartpollo_generator: ^0.1.0

Usage #

import 'package:dartpollo/dartpollo.dart';

// Basic client
final client = DartpolloClient(link: yourHttpLink);
final response = await client.execute(MyQuery());
print(response.data);

// Cached client
final cachedClient = DartpolloCachedClient(
  link: yourHttpLink,
  cacheStore: InMemoryCacheStore(),
);
final response = await cachedClient.execute(
  MyQuery(),
  cachePolicy: CachePolicy.cacheFirst,
);

API #

Clients #

  • DartpolloClient — Standard GraphQL client
  • DartpolloCachedClient — Client with caching support

Cache #

  • CacheStore — Abstract cache store interface
  • InMemoryCacheStore — In-memory cache implementation
  • HiveCacheStore — Persistent cache using Hive
  • CachePolicy — Cache behavior policies
  • CacheEntry — Individual cache entries
  • CacheContext — Cache context for requests

Migration Guide #

If you were using the old monolithic dartpollo package (before the monorepo split), follow these steps to migrate:

1. Update pubspec.yaml #

The code generator has been extracted into a separate package. Add dartpollo_generator as a dev dependency:

Before:

dependencies:
  dartpollo:
    # your version/path

dev_dependencies:
  build_runner: ^2.10.0

After:

dependencies:
  dartpollo: ^0.1.0

dev_dependencies:
  build_runner: ^2.10.0
  dartpollo_generator: ^0.1.0  # ← NEW: generator is now a separate package

Note: dartpollo_annotation is automatically included as a transitive dependency — you don't need to add it manually.

2. Update build.yaml #

Two changes are needed:

  1. Builder key changed from dartpollo: to dartpollo_generator|dartpollo: (fully qualified package|builder_name format)
  2. output option removed — output paths are now auto-generated under __generated__/ directories. Remove any output: entries from your schema_mapping.

Before:

targets:
  $default:
    sources:
      - $package$
      - lib/**
      - schema.graphql
    builders:
      dartpollo:
        options:
          schema_mapping:
            - schema: schema.graphql
              queries_glob: lib/**/*.graphql
              output: lib/__generated__

After:

targets:
  $default:
    sources:
      - $package$
      - lib/**
      - schema.graphql
    builders:
      dartpollo_generator|dartpollo:  # ← updated builder key
        options:
          schema_mapping:
            - schema: schema.graphql
              queries_glob: lib/**/*.graphql
              # output is no longer needed — auto-generated under __generated__/

For the full list of configuration options, see the dartpollo_generator README.

3. Regenerate code #

dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

4. No import changes needed #

All existing imports (package:dartpollo/dartpollo.dart) continue to work. The client barrel file re-exports all types from dartpollo_annotation, so generated code and your application code remain compatible without any import changes.

1
likes
160
points
30
downloads

Documentation

API reference

Publisher

verified publisherdwiky.my.id

Weekly Downloads

A Dart GraphQL client with caching support. Build dart types from GraphQL schemas and queries.

Repository (GitHub)
View/report issues

Topics

#graphql #client #codegen

License

MIT (license)

Dependencies

crypto, dartpollo_annotation, gql, gql_dedupe_link, gql_exec, gql_http_link, gql_link, hive_ce, http, json_annotation

More

Packages that depend on dartpollo