gql_gapher

Last updated:

0 purchases

gql_gapher Image
gql_gapher Images
Add to Cart

Description:

gql gapher

gql_gapher #

Tired of writing your queries & mutation as raw strings r""" """ in Dart and Flutter? 👋
Validate and generate typed request classes for all your queries and mutations defined in GraphQL (.graphql|.gql) files. It also supports Fragments.
Usage #
Add gql_gapher to your dev dependencies
dev_dependencies:
gql_gapher: any // required dart >=2.12.0
build_runner:
copied to clipboard
Write your queries & mutations #
mutation AuthenticateUser(
$first: String!
$second: Int!
$third: Boolean
$fourth: Float
) {
authenticate(
input: {
firebase: { token: $first }
data: { attempt: $second }
amount: $third
}
rememberMe: $fourth
) {
user {
id
email
phone
}
}
}
copied to clipboard
then run the generator
# dart
dart pub run build_runner build

# flutter
flutter pub run build_runner build
copied to clipboard
Use it #
import 'authenticate.g.dart';

void main() {

final authPreq = AuthenticateUserRequest('First', 2, third: true, fourth: 2.3);

print(authPreq.query); // query

print(authPreq.variables); // variables

print(authPreq.operation); // AuthenticateUser
}
copied to clipboard
More #
Fragments Support #
Fragment Imports are supported as seen in the sample below.
#import "../fragments/user_fragment.graphql"
#import "../fragments/location_fragment.graphql"

query GetUser($token: String!) {
authenticate(input: { firebase: { token: $token } }, rememberMe: true) {
location {
name
latitude
longitude
...LocationFragment
}
...UserFragment
}
}
copied to clipboard
Contributors ✨ #
Contributions of any kind welcome!

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.