Docs for generator

This commit is contained in:
Tobe O 2019-04-18 11:23:12 -04:00
parent 75556461d0
commit 7153ee1db2
6 changed files with 223 additions and 3 deletions

View file

@ -0,0 +1,3 @@
# 1.0.0-rc.1
* Add `CHANGELOG.md`, `example/main.dart`.
* Add documentation to `README.md`.

View file

@ -1,5 +1,50 @@
# graphql_generator
[![Pub](https://img.shields.io/pub/v/graphql_generator.svg)](https://pub.dartlang.org/packages/graphql_generator)
[![build status](https://travis-ci.org/angel-dart/graphql.svg)](https://travis-ci.org/angel-dart/graphql)
Generates `package:graphql_schema` schemas for
annotated class.
Documentation is yet to come.
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.
```dart
@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):
```dart
// 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)
]);
```

View file

@ -0,0 +1,14 @@
import 'package:graphql_schema/graphql_schema.dart';
part 'main.g.dart';
@graphQLClass
class Todo {
String text;
@GraphQLDocumentation(description: 'Whether this item is complete.')
bool isComplete;
}
void main() {
print(todoGraphQLType.fields.map((f) => f.name));
}

View file

@ -0,0 +1,16 @@
// 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)
]);

View file

@ -57,6 +57,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1+4"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.3"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.3"
built_collection:
dependency: transitive
description:
@ -155,6 +183,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2+1"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
html:
dependency: transitive
description:
@ -162,6 +197,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3+3"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
json_annotation:
dependency: transitive
description:
@ -197,6 +267,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+2"
package_config:
dependency: transitive
description:
@ -204,6 +281,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
package_resolver:
dependency: transitive
description:
name: package_resolver
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.10"
path:
dependency: transitive
description:
@ -211,6 +295,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
plugin:
dependency: transitive
description:
@ -218,6 +309,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+3"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
pub_semver:
dependency: transitive
description:
@ -253,6 +351,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.5"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
source_gen:
dependency: "direct main"
description:
@ -274,6 +386,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.17"
string_scanner:
dependency: transitive
description:
@ -288,6 +414,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+1"
typed_data:
dependency: transitive
description:
@ -309,6 +442,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+10"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.12"
yaml:
dependency: transitive
description:
@ -317,4 +457,4 @@ packages:
source: hosted
version: "2.1.15"
sdks:
dart: ">=2.1.0-dev.5.0 <3.0.0"
dart: ">=2.2.0 <3.0.0"

View file

@ -1,5 +1,5 @@
name: graphql_generator
version: 1.0.0-rc.0
version: 1.0.0-rc.1
description: Generates GraphQL schemas from Dart classes, for use with pkg:graphql_server.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/graphql
@ -14,3 +14,5 @@ dependencies:
graphql_schema: ^1.0.2
recase: ^2.0.0
source_gen: ^0.9.4
dev_dependencies:
build_runner: ^1.0.0