gql_cache_lens 1.0.0 copy "gql_cache_lens: ^1.0.0" to clipboard
gql_cache_lens: ^1.0.0 copied to clipboard

Platformweb

A Flutter DevTools Extension for inspecting GraphQL cache in your Flutter applications.

gql_cache_lens #

A Flutter DevTools extension for inspecting GraphQL cache

Features #

This package adds a new tool to Flutter's DevTools, utilizing the devtools_extensions framework. With this tool, you can:

  • View a list of data stored in the GraphQL cache store
    • The data list is categorized into three tabs: Cache, Query, and Mutation
  • Inspect the details of each cache entry

Supported GraphQL Packages #

Currently, gql_cache_lens supports the following GraphQL packages:

Screenshots #

Installation #

To install gql_cache_lens, add the package to your pubspec.yaml file:

dev_dependencies:
  gql_cache_lens: ^1.0.0

Alternatively, you can run the following command

flutter pub add --dev gql_cache_lens

Usage #

To use gql_cache_lens, add a ServiceExtensionHandler as shown below. Return a JSON-encoded Map obtained from the Store in the ServiceExtensionResponse's result.

For graphql package #

final GrpahQLClient client = ...;
registerExtension('ext.gql_cache_lens.load', (_, __) async {
  final GraphQLCache cache = client.cache;
  final Store store = cache.store;
  final cacheJson = jsonEncode(store.toMap());
  return ServiceExtensionResponse.result(cacheJson);
});

For ferry package #

final Client client = ...;
registerExtension('ext.gql_cache_lens.load', (_, __) async {
    final Cache cache = client.cache;
    final Store store = cache.store;
    final cacheEntries = store.keys.map((k) => MapEntry(k, store.get(k)));
    final cacheMap = Map.fromEntries(cacheEntries);
    final cacheJson = jsonEncode(cacheMap);
  return ServiceExtensionResponse.result(cacheJson);
});

Contributing #

Contributions are welcome! If you find a bug or have a feature request, please open an issue.

License #

This project is licensed under the MIT License. See the LICENSE file for details.

2
likes
150
points
67
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter DevTools Extension for inspecting GraphQL cache in your Flutter applications.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

devtools_extensions, flutter, google_fonts

More

Packages that depend on gql_cache_lens