A GQL Terminating Link To Execute Requests Via Dio Using JSON

Similar to gql_http_link, This is a GQL Terminating Link to execute requests via Dio using JSON.

Usage 

A simple usage example:

import "package:dio/dio.dart";
import "package:gql_link/gql_link.dart";
import "package:gql_dio_link/gql_dio_link.dart";

void main () {
  final dio = Dio();
  final link = Link.from([
    // SomeLink(),
    DioLink("/graphql", client: dio),
  ]);
}

Features and bugs 

Please file feature requests and bugs at the GitHub.

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add gql_dio_link

With Flutter:

 $ flutter pub add gql_dio_link

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  gql_dio_link: ^1.0.1+1

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:gql_dio_link/gql_dio_link.dart';

example/README.md

See https://github.com/gql-dart/gql/tree/master/examples/gql_example_dio_link

final client = dio.Dio();

final Link link = DioLink(
  graphqlEndpoint,
  client: client,
);

final res = await link
  .request(Request(
    operation: Operation(document: gql.parseString(
      """{
        countries(filter:{currency:{eq:"EGP"}}){
          name
        }
      }""",
    )),
  ))
  .first;

final countryName = res.data["countries"][0]["name"] as String;

print("The country that uses EGP as a form of curruncy is ${countryName}");

Download details:

Author: gql-dart.dev

Source: https://github.com/gql-dart/gql

#flutter #android #ios

A GQL Terminating Link To Execute Requests Via Dio Using JSON
1.60 GEEK