platform/graphql_server/test/query_test.dart

39 lines
878 B
Dart
Raw Normal View History

2018-08-02 15:17:14 +00:00
import 'package:graphql_schema/graphql_schema.dart';
import 'package:graphql_server/graphql_server.dart';
import 'package:test/test.dart';
void main() {
test('todo', () async {
var schema = graphQLSchema(
query: objectType('todo', [
field(
'text',
type: graphQLString,
resolve: (obj, args) => obj['text'],
),
field(
'completed',
type: graphQLBoolean,
resolve: (obj, args) => obj['completed'],
),
]),
);
var graphql = new GraphQL(schema);
var result = await graphql.parseAndExecute('{ text }', initialValue: {
'text': 'Clean your room!',
'completed': false,
});
print(result);
expect(result, {'text': 'Clean your room!'});
});
}
class Todo {
final String text;
final bool completed;
Todo({this.text, this.completed});
}