graphql_generator 1.0.0+1

graphql_generator #

Pub build status

Generates package:graphql_schema schemas for annotated class.

Replaces convertDartType from package:graphql_server.

Usage #

Usage is very simple. You just need a @graphQLClass or @GraphQLClass() annotation on any class you want to generate an object type for.

Individual fields can have a @GraphQLDocumentation() annotation, to provide information like descriptions, deprecation reasons, etc.

@graphQLClass
class Todo {
  String text;

  @GraphQLDocumentation(description: 'Whether this item is complete.')
  bool isComplete;
}

void main() {
  print(todoGraphQLType.fields.map((f) => f.name));
}

The following is generated (as of April 18th, 2019):

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'main.dart';

// **************************************************************************
// _GraphQLGenerator
// **************************************************************************

/// Auto-generated from [Todo].
final GraphQLObjectType todoGraphQLType = objectType('Todo',
    isInterface: false,
    interfaces: [],
    fields: [
      field('text', graphQLString),
      field('isComplete', graphQLBoolean)
    ]);

1.0.0+1 #

  • Replace snakeCase with camelCase.

1.0.0 #

  • Apply package:pedantic.

1.0.0-rc.1 #

  • Add CHANGELOG.md, example/main.dart.
  • Add documentation to README.md.

example/main.dart

import 'package:graphql_schema/graphql_schema.dart';
part 'main.g.dart';

@graphQLClass
class TodoItem {
  String text;

  @GraphQLDocumentation(description: 'Whether this item is complete.')
  bool isComplete;
}

void main() {
  print(todoItemGraphQLType.fields.map((f) => f.name));
}

Use this package as a library

1. Depend on it

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


dependencies:
  graphql_generator: ^1.0.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_generator/graphql_generator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
35
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: other

Primary library: package:graphql_generator/graphql_generator.dart with components: io, build, mirrors.

Health suggestions

Fix lib/graphql_generator.dart. (-0.50 points)

Analysis of lib/graphql_generator.dart reported 1 hint:

line 213 col 17: DO use curly braces for all flow control structures.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (build_config).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer >=0.27.1 <2.0.0 0.38.1
angel_model ^1.0.0 1.0.3
angel_serialize_generator ^2.0.0 2.5.0
build ^1.0.0 1.1.6
build_config ^0.3.0 0.3.2 0.4.1+1
code_builder ^3.0.0 3.2.0
graphql_schema ^1.0.2 1.0.4
recase ^2.0.0 2.0.1
source_gen ^0.9.4 0.9.4+4
Transitive dependencies
angel_serialize 2.2.3+2
args 1.5.2
async 2.3.0
built_collection 4.2.2
built_value 6.7.0
charcode 1.1.2
checked_yaml 1.0.2
code_buffer 1.0.1
collection 1.14.12
convert 2.1.1
crypto 2.1.2
csslib 0.16.1
dart_style 1.2.10
fixnum 0.10.9
front_end 0.1.23
glob 1.1.7
html 0.14.0+2
json_annotation 2.4.0 3.0.0
kernel 0.3.23
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
package_config 1.1.0
path 1.6.4
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.0.5
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.1.16
Dev dependencies
build_runner ^1.0.0
pedantic ^1.0.0 1.8.0+1