graphql_cache_inspector 0.0.2+1 graphql_cache_inspector: ^0.0.2+1 copied to clipboard
A Flutter Plugin that helps to inspect the graphql cache on device.
A Flutter Plugin that helps to inspect the graphql cache on device
Features #
- Visualizes the GraphQL Cache Data using simple lists
Usage #
import 'grapqhl_cache_inspector.dart' into your dart code.
import 'package:grapqhl_cache_inspector/grapqhl_cache_inspector.dart';
The GraphqlCacheInspector takes in a function that gets the cache data, as well as the data itself
GraphqlCacheInspector(
title: 'GraphQL Cache',
data: graphql.getCacheDump(),
getCacheData: graphql.getCacheDump,
);
You may perhaps use this as a page of its own by having a button that opens the CacheInspector, using something like
ElevatedButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: ((context) {
return GraphqlCacheInspector(
title: 'GraphQL Cache',
data: graphql.getCacheDump(),
getCacheData: graphql.getCacheDump,
);
}),
),
);
},
child: const Text('Get GraphQL Cache Dump'),
),
Here getCacheDump()
would be a function that converts your cache into json, the exact implementation would depend on your store
For example if using Hive as your cache store we would define this as
Map<dynamic, Map<dynamic, dynamic>?> getCacheDump() {
return hivestore.box.toMap();
}
Additional information #
This is a WIP new package, expect breaking changes.