platform/graphql_generator
2019-04-18 11:23:12 -04:00
..
example Docs for generator 2019-04-18 11:23:12 -04:00
lib Mysterious returns of "null" 2019-03-28 23:37:56 -04:00
.gitignore schema@1.0.3 2019-03-28 20:30:40 -04:00
analysis_options.yaml schema@1.0.3 2019-03-28 20:30:40 -04:00
build.yaml start generator 2019-02-03 16:03:47 -05:00
CHANGELOG.md Docs for generator 2019-04-18 11:23:12 -04:00
LICENSE graphql_gen 2019-04-16 11:15:24 -04:00
mono_pkg.yaml start generator 2019-02-03 16:03:47 -05:00
pubspec.lock Docs for generator 2019-04-18 11:23:12 -04:00
pubspec.yaml Docs for generator 2019-04-18 11:23:12 -04:00
README.md Docs for generator 2019-04-18 11:23:12 -04:00

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)
    ]);