pub server
This commit is contained in:
parent
9cbe33e604
commit
76015be604
3 changed files with 58 additions and 5 deletions
2
graphql_server/CHANGELOG.md
Normal file
2
graphql_server/CHANGELOG.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# 1.0.0-beta
|
||||
* First release.
|
52
graphql_server/example/main.dart
Normal file
52
graphql_server/example/main.dart
Normal file
|
@ -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});
|
||||
}
|
|
@ -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:
|
||||
test: ">=0.12.0 <2.0.0"
|
Loading…
Reference in a new issue