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