Skip to content

kevinrodriguez-io/flutter_graphql_hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter GraphQL Hooks 🪝

LOOKING FOR MAINTAINERS

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);

About

Apollo-like set of hooks to be used with flutter

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages