gql_link 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new69

A simple and modular AST-based GraphQL request execution interface.

Usage #

A simple usage example:

import "package:gql_link/gql_link.dart";
import "package:gql_dedupe_link/gql_dedupe_link.dart";
import "package:gql_http_link/gql_http_link.dart";

import "./my_custom_link.dart";

void main () {
  final link = Link.from([
    MyCustomLink(),
    DedupeLink()
    HttpLink("/graphql"),
  ]);
}

Features and bugs #

Please file feature requests and bugs at the GitHub.

0.2.0 #

  • rename Exception classes and extend from a new LinkException
  • add various Link utils: Link.function, Link.concat, Link.route and Link.split

0.1.0 #

  • split off of package:gql
  • add support for extensions
  • define common Link exceptions

example/gql_link_example.dart

import "package:gql/execution.dart";
import "package:gql/language.dart";
import "package:gql_link/gql_link.dart";

class MyLinkContext extends ContextEntry {
  final int value;

  const MyLinkContext(this.value);

  @override
  List<Object> get fieldsForEquality => null;
}

class MyLink extends Link {
  @override
  Stream<Response> request(Request request, [forward]) => Stream.fromIterable(
        [
          Response(
            data: <String, dynamic>{
              "context": request.context.entry<MyLinkContext>().value,
            },
          ),
        ],
      );
}

void main() async {
  final link = MyLink();

  for (var i = 0; i < 10; i++) {
    final first = await link
        .request(
          Request(
            operation: Operation(
              document: parseString(""),
            ),
            context: Context.fromMap(
              <Type, ContextEntry>{
                MyLinkContext: MyLinkContext(i),
              },
            ),
          ),
        )
        .first;

    print(first.data);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  gql_link: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:gql_link/gql_link.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:gql_link/gql_link.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
gql ^0.11.0 0.11.1
meta ^1.1.7 1.1.7
Transitive dependencies
charcode 1.1.2
collection 1.14.12
path 1.6.4
source_span 1.5.5
term_glyph 1.1.0
Dev dependencies
gql_pedantic ^1.0.0
mockito ^4.1.1
test ^1.0.0