built_graphql 1.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • 58

Built Value for GraphQL responses #

A library that contains basic built_value classes to help deserializing GraphQL responses.

Thanks for the great built_value library from Google.

Usage #

The example directory contains a Serializer definition and 2 basic classes.

First, add all of your classes to your serializer in the @SerializersFor. Then you have to add the GraphQLSerializerPlugin and StandardJsonPlugin.

For each type that you want to deserialize with GraphQLResponse, the serializer must contain a builder factory definition. Here is an example for Hero and Friend classes:

final standardSerializers = (serializers.toBuilder()

You can deserialize a Hero from GraphQL response by

final GraphQLResponse<Hero> response = standardSerializers.deserialize(
        specifiedType: GraphQLResponse.createFullTypeFor(Hero));

final Hero hero = response.data;

You can find more examples in the tests.

Limitations #

The library assumes that the name of the class, that will hold your data, and the key in the response are the same.

For the Hero class, the JSON response must have a hero key:

  "data": {
    "hero": {

Features and bugs #

The library supports only deserialization of the JSON responses. Serialization of the objects won't give the same result.

Please file feature requests and bugs at the issue tracker.

1.0.0 #

  • Initial version, created by dtengeri


import 'dart:convert';
import 'package:built_graphql/built_graphql.dart';

import 'hero.dart';
import 'serializers.dart';

void main() {
  final String jsonStr = '''
      "data": {
        "hero": {
          "name": "R2-D2",
          "heroFriends": [
              "id": "1000",
              "name": "Luke Skywalker"
              "id": "1002",
              "name": null
              "id": "1003",
              "name": "Leia Organa"
  final GraphQLResponse<Hero> response = standardSerializers.deserialize(
      specifiedType: GraphQLResponse.createFullTypeFor(Hero));


Use this package as a library

1. Depend on it

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

  built_graphql: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:built_graphql/built_graphql.dart';
Version Uploaded Documentation Archive
1.0.1 Feb 17, 2019 Go to the documentation of built_graphql 1.0.1 Download built_graphql 1.0.1 archive
1.0.0 Feb 14, 2019 Go to the documentation of built_graphql 1.0.0 Download built_graphql 1.0.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14


Detected platforms: Flutter, web, other

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
built_collection >=2.0.0 <5.0.0 4.1.0
built_value >=5.5.5 <7.0.0 6.3.1
Transitive dependencies
collection 1.14.11
fixnum 0.10.9
matcher 0.12.4
meta 1.1.7
path 1.6.2
quiver 2.0.1
stack_trace 1.9.3
Dev dependencies
build_runner ^1.0.0
built_value_generator ^6.3.0
pedantic ^1.0.0
test ^1.0.0