graphql_generator 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

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]
33
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: other

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

Health suggestions

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

Analysis of lib/graphql_generator.dart reported 2 hints:

line 169 col 30: 'type' is deprecated and shouldn't be used.

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.39.2
angel_model ^1.0.0 1.0.3
angel_serialize_generator ^2.0.0 2.5.0
build ^1.0.0 1.2.2
build_config ^0.3.0 0.3.2 0.4.1+1
code_builder ^3.0.0 3.2.1
graphql_schema ^1.0.2 1.0.4
recase ^2.0.0 2.0.1
source_gen ^0.9.4 0.9.4+6
Transitive dependencies
_fe_analyzer_shared 1.0.1
angel_serialize 2.2.3+3
args 1.5.2
async 2.4.0
built_collection 4.3.0
built_value 7.0.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.4
csslib 0.16.1
dart_style 1.3.3
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
json_annotation 2.4.0 3.0.0
logging 0.11.3+2
matcher 0.12.6
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.1.2+1
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+13
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0
pedantic ^1.0.0 1.9.0