graphql_builder 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 55

Build GraphQL queries in dart.

Example #

this code:

Document()
    .add(Query(name: "test")
        .addSelection(Field("title"))
        .addSelection(Field("name"))
        .addSelection(FragmentSpread("frag1")))
    .add(Fragment("frag1", TypeCondition("Cat"))
        .addSelection(Field("id"))
        .addSelection(Field("name")))
    .bake()

will generate this query:

query test {
  title
  name
  ...frag1
} 

fragment frag1 on Cat {
  id
  name
}

Usage #

add graphql_builder: ^1.0.0 to your dependencies

1.0.0 #

  • Initial version, created by Stagehand

example/graphql_builder_example.dart

import 'package:graphql_builder/graphql_builder.dart';

main() {
  print(Document().add(Query().addSelection(Field("id"))));
}

Use this package as a library

1. Depend on it

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


dependencies:
  graphql_builder: ^1.0.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:graphql_builder/graphql_builder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

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

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Health issues and suggestions

Document public APIs. (-1 points)

163 out of 163 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/graphql_builder.dart.

Run dartfmt to format lib/graphql_builder.dart.

Format lib/src/Argument.dart.

Run dartfmt to format lib/src/Argument.dart.

Format lib/src/Base.dart.

Run dartfmt to format lib/src/Base.dart.

Fix additional 9 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/Definition/Definition.dart (Run dartfmt to format lib/src/Definition/Definition.dart.)
  • lib/src/Directive/SkipDirective.dart (Run dartfmt to format lib/src/Directive/SkipDirective.dart.)
  • lib/src/Selection/Field.dart (Run dartfmt to format lib/src/Selection/Field.dart.)
  • lib/src/Selection/InlineFragment.dart (Run dartfmt to format lib/src/Selection/InlineFragment.dart.)
  • lib/src/Selection/Selection.dart (Run dartfmt to format lib/src/Selection/Selection.dart.)
  • lib/src/Value/ConstValue/ArrayConst.dart (Run dartfmt to format lib/src/Value/ConstValue/ArrayConst.dart.)
  • lib/src/Value/ConstValue/ConstValue.dart (Run dartfmt to format lib/src/Value/ConstValue/ConstValue.dart.)
  • lib/src/Value/Value.dart (Run dartfmt to format lib/src/Value/Value.dart.)
  • lib/src/VariableType.dart (Run dartfmt to format lib/src/VariableType.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
pedantic ^1.0.0
test ^1.0.0