flutter_graphql_hooks: ^1.0.2-beta copied to clipboard
A colleciton of apollo-like GraphQL Hooks to improve code readability.
Flutter GraphQL Hooks 🪝
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!
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);