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
- Host: GitHub
- URL: https://github.com/kevinrodriguez-io/flutter_graphql_hooks
- Owner: kevinrodriguez-io
- License: mit
- Created: 2021-02-05T02:23:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-14T07:43:08.000Z (about 4 years ago)
- Last Synced: 2023-08-20T21:58:35.986Z (about 2 years ago)
- Topics: apollo, flutter-graphql, flutter-graphql-hooks, hooks
- Language: Dart
- Homepage:
- Size: 21.5 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Flutter GraphQL Hooks 🪝
LOOKING FOR MAINTAINERS
# 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);
```