graphql_schema 1.0.0-beta

  • README.md
  • Installing
  • Versions
  • 41

graphql_schema

Pub

An implementation of GraphQL's type system in Dart. Supports any platform where Dart runs.

Usage

It's easy to define a schema with the helper functions:

final GraphQLSchema todoSchema = new GraphQLSchema(
    query: objectType('Todo', [
  field('text', type: graphQLString.nonNullable()),
  field('created_at', type: graphQLDate)
]));

All GraphQL types are generic, in order to leverage Dart's strong typing support.

Serialization

GraphQL types can serialize and deserialize input data. The exact implementation of this depends on the type.

var iso8601String = graphQLDate.serialize(new DateTime.now());
var date = graphQLDate.deserialize(iso8601String);
print(date.millisecondsSinceEpoch);

Validation

GraphQL types can validate input data.

var validation = myType.validate('@root', {...});

if (validation.successful) {
  doSomething(validation.value);
} else {
  print(validation.errors);
}

Helpers

  • graphQLSchema - Create a GraphQLSchema
  • objectType - Create a GraphQLObjectType with fields
  • field - Create a GraphQLField with a type/argument/resolver
  • listType - Create a GraphQLListType with the provided innerType

Types

All of the GraphQL scalar types are built in, as well as a Date type:

  • graphQLString
  • graphQLId
  • graphQLBoolean
  • graphQLInt
  • graphQLFloat
  • graphQLDate

Non-Nullable Types

You can easily make a type non-nullable by calling its nonNullable method.

List Types

Support for list types is also included. Use the listType helper for convenience.

/// A non-nullable list of non-nullable integers
listType(graphQLInt.nonNullable()).nonNullable();

1. Depend on it

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


dependencies:
  graphql_schema: "^1.0.0-beta"

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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:graphql_schema/graphql_schema.dart';
        
Version Uploaded Documentation Archive
1.0.0-beta Jul 19, 2017 Go to the documentation of graphql_schema 1.0.0-beta Download graphql_schema 1.0.0-beta archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
22 / 100
Health:
Code health derived from static analysis. [more]
55 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
66 / 100
Overall score:
Weighted score of the above. [more]
41

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix lib/src/schema.dart.

    Strong-mode analysis of lib/src/schema.dart failed with the following error:

    line: 4 col: 8
    Target of URI doesn't exist: 'package:meta/meta.dart'.

  • Fix lib/src/scalar.dart.

    Strong-mode analysis of lib/src/scalar.dart failed with the following error:

    line: 28 col: 5
    Base class introduces an invalid override. The type of 'GraphQLType.deserialize' ('(Serialized) → Value') isn't a subtype of 'GraphQLType<dynamic, dynamic>.deserialize' ('(dynamic) → dynamic').

  • Fix further 1 Dart files.

    Similar analysis of the following files failed:

    • lib/src/object_type.dart
  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 3 error(s) and 0 warning(s).

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use graphql_schema.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0
graphql_parser ^1.0.0 1.0.0+1
Transitive dependencies
charcode 1.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
Dev dependencies
test ^0.12.0