An open API service indexing awesome lists of open source software.

https://github.com/kevinrodriguez-io/flutter_graphql_hooks

Apollo-like set of hooks to be used with flutter
https://github.com/kevinrodriguez-io/flutter_graphql_hooks

apollo flutter-graphql flutter-graphql-hooks hooks

Last synced: 3 months ago
JSON representation

Apollo-like set of hooks to be used with flutter

Awesome Lists containing this project

README

          

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:

```dart
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] and will have proper typings!
```

# Installing

```yml
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:

```dart
final rooms = useQuery(QueryOptions(
document: query.document,
variables: query.getVariablesMap(),
), client: myGraphqlClient);
```