graphql_generator 1.0.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

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

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on ios

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on linux

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on macos

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-native on windows

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/utils.dartpackage:build/build.dartpackage:build/src/generate/run_post_process_builder.dartpackage:build/src/builder/post_process_builder.dartpackage:build/src/builder/builder.dartpackage:build/src/builder/build_step.dartpackage:build/src/asset/reader.dartpackage:glob/glob.dartpackage:glob/src/list_tree.dartpackage:glob/src/io.dartpackage:glob/src/io_export.dartdart:io

Package not compatible with runtime native-aot

Because of the import of dart:mirrors via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/type_checker.dartdart:mirrors

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:graphql_generator/graphql_generator.dartpackage:source_gen/source_gen.dartpackage:source_gen/src/utils.dartpackage:build/build.dartpackage:build/src/generate/run_post_process_builder.dartpackage:build/src/builder/post_process_builder.dartpackage:build/src/builder/builder.dartpackage:build/src/builder/build_step.dartpackage:build/src/asset/reader.dartpackage:glob/glob.dartpackage:glob/src/list_tree.dartpackage:glob/src/io.dartpackage:glob/src/io_export.dartdart:io

Health suggestions

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

Analysis of lib/graphql_generator.dart reported 8 hints, including:

line 63 col 17: 'name' is deprecated and shouldn't be used. Check element, or use getDisplayString().

line 64 col 15: 'name' is deprecated and shouldn't be used. Check element, or use getDisplayString().

line 65 col 15: 'name' is deprecated and shouldn't be used. Check element, or use getDisplayString().

line 157 col 23: 'name' is deprecated and shouldn't be used. Check element, or use getDisplayString().

line 158 col 21: 'name' is deprecated and shouldn't be used. Check element, or use getDisplayString().

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (build_config, recase).

Package is getting outdated. (-18.90 points)

The package was last published 62 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer >=0.27.1 <2.0.0 0.39.11
angel_model ^1.0.0 1.0.3
angel_serialize_generator ^2.0.0 2.5.0
build ^1.0.0 1.3.0
build_config ^0.3.0 0.3.2 0.4.2
code_builder ^3.0.0 3.3.0
graphql_schema ^1.0.2 1.0.4
recase ^2.0.0 2.0.1 3.0.0
source_gen ^0.9.4 0.9.5
Transitive dependencies
_fe_analyzer_shared 5.0.0
angel_serialize 2.2.3+3
args 1.6.0
async 2.4.1
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
checked_yaml 1.0.2
code_buffer 1.0.1
collection 1.14.13
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
js 0.6.2
json_annotation 2.4.0 3.0.1
logging 0.11.4
matcher 0.12.8
meta 1.1.8
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
path 1.7.0
pub_semver 1.4.4
pubspec_parse 0.1.5
quiver 2.1.3
quiver_hashcode 2.0.0
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_runner ^1.0.0
pedantic ^1.0.0 1.9.0 1.9.1