Prep Angel for publish

This commit is contained in:
Tobe O 2018-11-01 17:27:36 -04:00
parent 9c111d9837
commit 2c703d57dc
8 changed files with 38 additions and 28 deletions

View file

@ -0,0 +1,2 @@
# 1.0.0-alpha
* First official release.

View file

@ -1,4 +1,5 @@
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_graphql/angel_graphql.dart';
import 'package:angel_serialize/angel_serialize.dart';
import 'package:graphql_schema/graphql_schema.dart';
@ -17,7 +18,7 @@ main() async {
if (rec.stackTrace != null) print(rec.stackTrace);
});
var todoService = app.use('api/todos', new MapService()) as Service;
var todoService = app.use('api/todos', new MapService());
var queryType = objectType(
'Query',

View file

@ -1,6 +1,5 @@
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:http_parser/http_parser.dart';
/// Returns a simple [RequestHandler] that renders the GraphiQL visual interface for GraphQL.
///
@ -9,9 +8,9 @@ import 'package:angel_framework/angel_framework.dart';
RequestHandler graphiQL({String graphQLEndpoint: '/graphql'}) {
return (req, res) {
res
..contentType = new ContentType('text', 'html')
..contentType = new MediaType('text', 'html')
..write(renderGraphiql(graphqlEndpoint: graphQLEndpoint))
..end();
..close();
};
}

View file

@ -28,9 +28,10 @@ RequestHandler graphQLHttp(GraphQL graphQL) {
};
executeMap(Map map) async {
var text = req.body['query'] as String;
var operationName = req.body['operation_name'] as String;
var variables = req.body['variables'];
var body = await req.parseBody();
var text = body['query'] as String;
var operationName = body['operation_name'] as String;
var variables = body['variables'];
if (variables is String) {
variables = json.decode(variables as String);
@ -49,12 +50,12 @@ RequestHandler graphQLHttp(GraphQL graphQL) {
try {
if (req.method == 'GET') {
if (await validateQuery(graphQlPostBody)(req, res)) {
return await executeMap(req.query);
if (await validateQuery(graphQlPostBody)(req, res) as bool) {
return await executeMap(await req.parseQuery());
}
} else if (req.method == 'POST') {
if (req.headers.contentType?.mimeType == graphQlContentType.mimeType) {
var text = utf8.decode(await req.lazyOriginalBuffer());
var text = utf8.decode(await req.parseRawRequestBuffer());
return {
'data': await graphQL.parseAndExecute(
text,
@ -63,8 +64,8 @@ RequestHandler graphQLHttp(GraphQL graphQL) {
),
};
} else if (req.headers.contentType?.mimeType == 'application/json') {
if (await validate(graphQlPostBody)(req, res)) {
return await executeMap(req.body);
if (await validate(graphQlPostBody)(req, res) as bool) {
return await executeMap(await req.parseBody());
}
} else {
throw new AngelHttpException.badRequest();

View file

@ -2,7 +2,7 @@ import 'package:angel_framework/angel_framework.dart';
import 'package:graphql_schema/graphql_schema.dart';
Map<String, dynamic> _fetchRequestInfo(Map<String, dynamic> arguments) {
return <String, dynamic> {
return <String, dynamic>{
'__requestctx': arguments.remove('__requestctx'),
'__responsectx': arguments.remove('__responsectx'),
};
@ -16,7 +16,8 @@ GraphQLFieldResolver<Value, Serialized>
resolveViaServiceIndex<Value, Serialized>(Service service) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
return await service.index(params) as Value;
};
@ -30,7 +31,8 @@ GraphQLFieldResolver<Value, Serialized>
resolveViaServiceFindOne<Value, Serialized>(Service service) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
return await service.findOne(params) as Value;
};
}
@ -47,7 +49,8 @@ GraphQLFieldResolver<Value, Serialized>
{String idField: 'id'}) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
var id = arguments.remove(idField);
return await service.read(id, params) as Value;
};
@ -66,7 +69,8 @@ GraphQLFieldResolver<Value, Serialized>
{String idField: 'id'}) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
var id = arguments.remove(idField);
return await service.modify(id, arguments['data'], params) as Value;
};
@ -88,7 +92,8 @@ GraphQLFieldResolver<Value, Serialized>
{String idField: 'id'}) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
var id = arguments.remove(idField);
return await service.update(id, arguments['data'], params) as Value;
};
@ -106,7 +111,8 @@ GraphQLFieldResolver<Value, Serialized>
{String idField: 'id'}) {
return (_, arguments) async {
var _requestInfo = _fetchRequestInfo(arguments);
var params = {'query': arguments, 'provider': Providers.graphql}..addAll(_requestInfo);
var params = {'query': arguments, 'provider': Providers.graphQL}
..addAll(_requestInfo);
var id = arguments.remove(idField);
return await service.remove(id, params) as Value;
};

View file

@ -1,14 +1,15 @@
name: angel_graphql
version: 1.0.0-alpha
description: The fastest + easiest way to get a GraphQL backend in Dart, using Angel.
homepage: https://github.com/angel-dart/graphql
author: Tobe O <thosakwe@gmail.com>
environment:
sdk: ">=1.8.0 <3.0.0"
sdk: ">=2.0.0-dev <3.0.0"
dependencies:
angel_framework: ^2.0.0-alpha
angel_validate: ^1.0.0
graphql_parser:
path: ../graphql_parser
graphql_schema:
path: ../graphql_schema
graphql_server:
path: ../graphql_server
angel_validate: ^2.0.0-alpha
graphql_parser: ^1.0.0
graphql_schema: ^1.0.0
graphql_server: ^1.0.0-beta
dev_dependencies:
angel_serialize: ^2.0.0

BIN
img/angel_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
img/angel_logo.xcf Normal file

Binary file not shown.