diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml
index dacfcb0..2060041 100644
--- a/.github/workflows/dart.yml
+++ b/.github/workflows/dart.yml
@@ -23,7 +23,7 @@ jobs:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
- uses: dart-lang/setup-dart@v1
with:
- sdk: "3.6.1"
+ sdk: "3.8.3"
# Graphql Schema
- id: graphql_schema2_upgrade
diff --git a/packages/angel_graphql/example/main.dart b/packages/angel_graphql/example/main.dart
index 51c9c71..c123446 100644
--- a/packages/angel_graphql/example/main.dart
+++ b/packages/angel_graphql/example/main.dart
@@ -12,13 +12,14 @@ import 'package:logging/logging.dart';
void main() async {
var logger = Logger('angel3_graphql');
var app = Angel(
- reflector: MirrorsReflector(),
- logger: logger
- ..onRecord.listen((rec) {
- print(rec);
- if (rec.error != null) print(rec.error);
- if (rec.stackTrace != null) print(rec.stackTrace);
- }));
+ reflector: MirrorsReflector(),
+ logger: logger
+ ..onRecord.listen((rec) {
+ print(rec);
+ if (rec.error != null) print(rec.error);
+ if (rec.stackTrace != null) print(rec.stackTrace);
+ }),
+ );
var http = AngelHttp(app);
var todoService = app.use('api/todos', MapService());
@@ -36,9 +37,7 @@ void main() async {
'todo',
convertDartType(Todo)!,
resolve: resolveViaServiceRead(todoService),
- inputs: [
- GraphQLFieldInput('id', graphQLId.nonNullable()),
- ],
+ inputs: [GraphQLFieldInput('id', graphQLId.nonNullable())],
),
],
);
@@ -52,33 +51,39 @@ void main() async {
convertDartType(Todo)!,
inputs: [
GraphQLFieldInput(
- 'data', convertDartType(Todo)!.coerceToInputObject()),
+ 'data',
+ convertDartType(Todo)!.coerceToInputObject(),
+ ),
],
resolve: resolveViaServiceCreate(todoService),
),
],
);
- var schema = graphQLSchema(
- queryType: queryType,
- mutationType: mutationType,
- );
+ var schema = graphQLSchema(queryType: queryType, mutationType: mutationType);
app.all('/graphql', graphQLHttp(GraphQL(schema)));
app.get('/graphiql', graphiQL());
- await todoService
- .create({'text': 'Clean your room!', 'completion_status': 'COMPLETE'});
- await todoService.create(
- {'text': 'Take out the trash', 'completion_status': 'INCOMPLETE'});
+ await todoService.create({
+ 'text': 'Clean your room!',
+ 'completion_status': 'COMPLETE',
+ });
+ await todoService.create({
+ 'text': 'Take out the trash',
+ 'completion_status': 'INCOMPLETE',
+ });
await todoService.create({
'text': 'Become a billionaire at the age of 5',
- 'completion_status': 'INCOMPLETE'
+ 'completion_status': 'INCOMPLETE',
});
var server = await http.startServer('127.0.0.1', 3000);
- var uri =
- Uri(scheme: 'http', host: server.address.address, port: server.port);
+ var uri = Uri(
+ scheme: 'http',
+ host: server.address.address,
+ port: server.port,
+ );
var graphiqlUri = uri.replace(path: 'graphiql');
print('Listening at $uri');
print('Access graphiql at $graphiqlUri');
@@ -91,7 +96,8 @@ abstract class HasText {
@serializable
@GraphQLDocumentation(
- description: 'A task that might not be completed yet. **Yay! Markdown!**')
+ description: 'A task that might not be completed yet. **Yay! Markdown!**',
+)
class Todo extends Model implements HasText {
@override
String? text;
diff --git a/packages/angel_graphql/example/subscription.dart b/packages/angel_graphql/example/subscription.dart
index 703832e..b137a62 100644
--- a/packages/angel_graphql/example/subscription.dart
+++ b/packages/angel_graphql/example/subscription.dart
@@ -23,8 +23,10 @@ void main() async {
// Create an in-memory service.
var fs = LocalFileSystem();
- var postService =
- app.use('/api/posts', JsonFileService(fs.file('posts.json')));
+ var postService = app.use(
+ '/api/posts',
+ JsonFileService(fs.file('posts.json')),
+ );
// Also get a [Stream] of item creation events.
var postAdded = postService.afterCreated
@@ -33,10 +35,10 @@ void main() async {
.asBroadcastStream();
// GraphQL setup.
- var postType = objectType('Post', fields: [
- field('author', graphQLString),
- field('comment', graphQLString),
- ]);
+ var postType = objectType(
+ 'Post',
+ fields: [field('author', graphQLString), field('comment', graphQLString)],
+ );
var schema = graphQLSchema(
// Hooked up to the postService:
@@ -64,7 +66,9 @@ void main() async {
postType,
inputs: [
GraphQLFieldInput(
- 'data', postType.toInputObject('PostInput').nonNullable()),
+ 'data',
+ postType.toInputObject('PostInput').nonNullable(),
+ ),
],
resolve: resolveViaServiceCreate(postService),
),
@@ -75,22 +79,27 @@ void main() async {
// type Subscription { postAdded: Post }
subscriptionType: objectType(
'Subscription',
- fields: [
- field('postAdded', postType, resolve: (_, __) => postAdded),
- ],
+ fields: [field('postAdded', postType, resolve: (_, __) => postAdded)],
),
);
// Mount GraphQL routes; we'll support HTTP and WebSockets transports.
app.all('/graphql', graphQLHttp(GraphQL(schema)));
- app.get('/subscriptions',
- graphQLWS(GraphQL(schema), keepAliveInterval: Duration(seconds: 3)));
- app.get('/graphiql',
- graphiQL(subscriptionsEndpoint: 'ws://localhost:3000/subscriptions'));
+ app.get(
+ '/subscriptions',
+ graphQLWS(GraphQL(schema), keepAliveInterval: Duration(seconds: 3)),
+ );
+ app.get(
+ '/graphiql',
+ graphiQL(subscriptionsEndpoint: 'ws://localhost:3000/subscriptions'),
+ );
var server = await http.startServer('127.0.0.1', 3000);
- var uri =
- Uri(scheme: 'http', host: server.address.address, port: server.port);
+ var uri = Uri(
+ scheme: 'http',
+ host: server.address.address,
+ port: server.port,
+ );
var graphiqlUri = uri.replace(path: 'graphiql');
var postsUri = uri.replace(pathSegments: ['api', 'posts']);
print('Listening at $uri');
diff --git a/packages/angel_graphql/lib/src/graphiql.dart b/packages/angel_graphql/lib/src/graphiql.dart
index 976e47c..6cdcaf1 100644
--- a/packages/angel_graphql/lib/src/graphiql.dart
+++ b/packages/angel_graphql/lib/src/graphiql.dart
@@ -5,20 +5,27 @@ import 'package:http_parser/http_parser.dart';
///
/// By default, the interface expects your backend to be mounted at `/graphql`; this is configurable
/// via [graphQLEndpoint].
-RequestHandler graphiQL(
- {String graphQLEndpoint = '/graphql', String? subscriptionsEndpoint}) {
+RequestHandler graphiQL({
+ String graphQLEndpoint = '/graphql',
+ String? subscriptionsEndpoint,
+}) {
return (req, res) {
res
..contentType = MediaType('text', 'html')
- ..write(renderGraphiql(
+ ..write(
+ renderGraphiql(
graphqlEndpoint: graphQLEndpoint,
- subscriptionsEndpoint: subscriptionsEndpoint))
+ subscriptionsEndpoint: subscriptionsEndpoint,
+ ),
+ )
..close();
};
}
-String renderGraphiql(
- {String graphqlEndpoint = '/graphql', String? subscriptionsEndpoint}) {
+String renderGraphiql({
+ String graphqlEndpoint = '/graphql',
+ String? subscriptionsEndpoint,
+}) {
var subscriptionsScripts = '',
subscriptionsFetcher = '',
fetcherName = 'graphQLFetcher';
@@ -29,7 +36,8 @@ String renderGraphiql(
''';
- subscriptionsFetcher = '''
+ subscriptionsFetcher =
+ '''
let subscriptionsClient = window.SubscriptionsTransportWs.SubscriptionClient('$subscriptionsEndpoint', {
reconnect: true
});
diff --git a/packages/angel_graphql/lib/src/graphql_http.dart b/packages/angel_graphql/lib/src/graphql_http.dart
index f2b4a2b..4bbde1a 100644
--- a/packages/angel_graphql/lib/src/graphql_http.dart
+++ b/packages/angel_graphql/lib/src/graphql_http.dart
@@ -22,9 +22,11 @@ final RegExp _num = RegExp(r'^[0-9]+$');
///
/// Follows the guidelines listed here:
/// https://graphql.org/learn/serving-over-http/
-RequestHandler graphQLHttp(GraphQL graphQL,
- {Function(RequestContext, ResponseContext, Stream