flutter_graphql_hooks 1.0.4-beta copy "flutter_graphql_hooks: ^1.0.4-beta" to clipboard
flutter_graphql_hooks: ^1.0.4-beta copied to clipboard

A colleciton of apollo-like GraphQL Hooks to improve code readability.

Flutter GraphQL Hooks 🪝

Watch on GitHub Star on GitHub Tweet!

Introduction #

This package exposes an apollo-like set of hooks to be used with flutter, it's meant to be used together with the graphql_flutter package and it's based on it's latest implementation.

It can be used along with artemis to provide strongly typed hooks, example:

final query = GetRoomsQuery(variables: GetRoomsArguments(limit: 10, offset: 0));

final rooms = useQuery(QueryOptions(
  document: query.document,
  variables: query.getVariablesMap(),
));

final loading = rooms.result.loading;
final error = rooms.result.error;
final data = query.parse(rooms.result.data);
// Data will no longer be a [Map<String, dynamic>] and will have proper typings! 

Installing #

dependencies:
  flutter_graphql_hooks:

Notes #

In order to use the hooks, a GraphqlProvider must exist on the build context. Otherwise you'll need to manually pass the client in the hook as a parameter like:

final rooms = useQuery(QueryOptions(
  document: query.document,
  variables: query.getVariablesMap(),
), client: myGraphqlClient);
4
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A colleciton of apollo-like GraphQL Hooks to improve code readability.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, flutter_hooks, graphql_flutter

More

Packages that depend on flutter_graphql_hooks