From 76015be604e0128e300182cf64e9bb943ad5acfd Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 23 Oct 2018 12:07:49 -0400 Subject: [PATCH] pub server --- graphql_server/CHANGELOG.md | 2 ++ graphql_server/example/main.dart | 52 ++++++++++++++++++++++++++++++++ graphql_server/pubspec.yaml | 9 +++--- 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 graphql_server/CHANGELOG.md create mode 100644 graphql_server/example/main.dart diff --git a/graphql_server/CHANGELOG.md b/graphql_server/CHANGELOG.md new file mode 100644 index 00000000..ed659017 --- /dev/null +++ b/graphql_server/CHANGELOG.md @@ -0,0 +1,2 @@ +# 1.0.0-beta +* First release. \ No newline at end of file diff --git a/graphql_server/example/main.dart b/graphql_server/example/main.dart new file mode 100644 index 00000000..c008fb84 --- /dev/null +++ b/graphql_server/example/main.dart @@ -0,0 +1,52 @@ +import 'package:graphql_schema/graphql_schema.dart'; +import 'package:graphql_server/graphql_server.dart'; +import 'package:test/test.dart'; + +void main() { + test('single element', () async { + var todoType = objectType('todo', fields: [ + field( + 'text', + graphQLString, + resolve: (obj, args) => obj.text, + ), + field( + 'completed', + graphQLBoolean, + resolve: (obj, args) => obj.completed, + ), + ]); + + var schema = graphQLSchema( + queryType: objectType('api', fields: [ + field( + 'todos', + listOf(todoType), + resolve: (_, __) => [ + new Todo( + text: 'Clean your room!', + completed: false, + ) + ], + ), + ]), + ); + + var graphql = new GraphQL(schema); + var result = await graphql.parseAndExecute('{ todos { text } }'); + + print(result); + expect(result, { + 'todos': [ + {'text': 'Clean your room!'} + ] + }); + }); +} + +class Todo { + final String text; + final bool completed; + + Todo({this.text, this.completed}); +} diff --git a/graphql_server/pubspec.yaml b/graphql_server/pubspec.yaml index 7453104e..b31e839c 100644 --- a/graphql_server/pubspec.yaml +++ b/graphql_server/pubspec.yaml @@ -1,15 +1,14 @@ name: graphql_server +version: 1.0.0-beta environment: sdk: ">=1.8.0 <3.0.0" dependencies: angel_serialize: ^2.0.0 collection: ^1.0.0 - graphql_schema: - path: ../graphql_schema - graphql_parser: - path: ../graphql_parser + graphql_schema: ^1.0.0 + graphql_parser: ^1.0.0 meta: ^1.0.0 recase: ^2.0.0 tuple: ^1.0.0 dev_dependencies: - test: \ No newline at end of file + test: ">=0.12.0 <2.0.0" \ No newline at end of file