platform/packages/graphql/graphql_generator
2020-04-05 12:39:49 +02:00
..
example Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
lib Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
.gitignore Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
analysis_options.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
build.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
CHANGELOG.md Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
LICENSE Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
mono_pkg.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
pubspec.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
README.md Small update in README 2020-04-05 12:39:49 +02: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
@GraphQLDocumentation(description: 'Todo object type')
class Todo {
  String text;

  /// 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,
    description: 'Todo object type',
    interfaces: [],
    fields: [
      field('text', graphQLString),
      field('isComplete', graphQLBoolean, description: 'Whether this item is complete')
    ]);