Compare commits
17 commits
master
...
v7/angel3-
Author | SHA1 | Date | |
---|---|---|---|
|
9e7c29a3a4 | ||
|
71e10b57d2 | ||
|
b3b5d01aec | ||
|
563f7f8dde | ||
|
8facd65c14 | ||
|
d8c3736955 | ||
|
8c63811c50 | ||
|
5c4eded653 | ||
|
16565c26cd | ||
|
9d9a94965e | ||
|
77b61d30ed | ||
|
35b4706078 | ||
|
9f59ab1336 | ||
|
45f1a2f6f6 | ||
|
708502e0dc | ||
|
0148812c60 | ||
|
9cfb56f123 |
20 changed files with 326 additions and 96 deletions
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
|
@ -1,3 +0,0 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: [thosakwe]
|
28
.gitignore
vendored
28
.gitignore
vendored
|
@ -11,7 +11,6 @@
|
|||
.project
|
||||
.pub/
|
||||
.scripts-bin/
|
||||
.metals/
|
||||
build/
|
||||
**/packages/
|
||||
|
||||
|
@ -38,27 +37,7 @@ pubspec.lock
|
|||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
.vscode/
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
@ -81,11 +60,8 @@ crashlytics-build.properties
|
|||
fabric.properties
|
||||
|
||||
### VSCode template
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.vscode/
|
||||
.metals/
|
||||
|
||||
logs/
|
||||
*.pem
|
||||
|
|
12
AUTHORS.md
12
AUTHORS.md
|
@ -1,12 +0,0 @@
|
|||
Primary Authors
|
||||
===============
|
||||
|
||||
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
|
||||
|
||||
Thomas is the current maintainer of the code base. He has refactored and migrated the
|
||||
code base to support NNBD.
|
||||
|
||||
* __[Tobe O](thosakwe@gmail.com)__
|
||||
|
||||
Tobe has written much of the original code prior to NNBD migration. He has moved on and
|
||||
is no longer involved with the project.
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
# Contribution
|
||||
|
||||
Any help from the open-source community is always welcome and needed:
|
||||
|
||||
1. Found an issue?
|
||||
- Please [fill a bug report][tracker] with error message and steps to reproduce it.
|
||||
2. Wish a feature?
|
||||
- Open a feature request with use cases.
|
||||
3. Are you using and liking the project?
|
||||
- Create an article about your use case
|
||||
- Do a post on your likes and dislikes
|
||||
- Make a donation.
|
||||
4. Are you a developer?
|
||||
- Fix a bug and send a [pull request][pull_request]
|
||||
- Implement a new feature
|
||||
- Improve the Unit Tests
|
||||
- Improve the [User Guide][doc] and send a [document pull request][doc_repo]
|
||||
5. Have you already helped in any way?
|
||||
- **Many thanks to the contributors and everybody that uses this project!**
|
||||
|
||||
[tracker]: https://github.com/dukefirehawk/angel/issues
|
||||
[pull_request]: https://github.com/dukefirehawk/angel/pulls
|
||||
[doc]: https://angel3-docs.dukefirehawk.com
|
||||
[doc_repo]: https://github.com/dukefirehawk/angel3-guide/pulls
|
|
@ -1,7 +1,6 @@
|
|||
# Graphql Starter Application for Angel3 framework
|
||||
|
||||
# Basic Starter Application for Angel3 framework
|
||||
|
||||
This is a basic starter application for [Angel3 framework](https://angel3-framework.web.app) which is a full-stack Web framework in Dart.
|
||||
This is a graphql starter application for [Angel3 framework](https://angel3-framework.web.app) which is a full-stack Web framework in Dart.
|
||||
|
||||
## Installation & Setup
|
||||
|
||||
|
@ -32,3 +31,5 @@ This is a basic starter application for [Angel3 framework](https://angel3-framew
|
|||
Visit the [Developer Guide](https://angel3-docs.dukefirehawk.com/guides) for dozens of guides and resources, including video tutorials, to get up and running as quickly as possible with Angel3.
|
||||
|
||||
Examples and complete projects can be found [here](https://angel3-framework.web.app/#/examples).
|
||||
|
||||
You can also view the [API Documentation](https://pub.dev/documentation/angel3_framework/latest/).
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import 'dart:io';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:belatuk_pretty_logging/belatuk_pretty_logging.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
import 'package:angel3_container/mirrors.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_hot/angel3_hot.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
void main() async {
|
||||
// Watch the config/ and web/ directories for changes, and hot-reload the server.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:angel/angel.dart';
|
||||
import 'package:angel3_container/mirrors.dart';
|
||||
import 'package:angel3_production/angel3_production.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
|
||||
// NOTE: By default, the Runner class does not use the `MirrorsReflector`, or any
|
||||
// reflector, by default.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/// Configuration for this Angel instance.
|
||||
import 'package:angel3_configuration/angel3_configuration.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_jael/angel3_jael.dart';
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/// Custom plugins go here.
|
||||
import 'dart:async';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
|
||||
|
|
11
lib/src/models/todo.dart
Normal file
11
lib/src/models/todo.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
import 'package:graphql_schema2/graphql_schema2.dart';
|
||||
part 'todo.g.dart';
|
||||
|
||||
@graphQLClass
|
||||
@serializable
|
||||
abstract class _Todo extends Model {
|
||||
String? get text;
|
||||
|
||||
bool? get isComplete;
|
||||
}
|
155
lib/src/models/todo.g.dart
Normal file
155
lib/src/models/todo.g.dart
Normal file
|
@ -0,0 +1,155 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'todo.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonModelGenerator
|
||||
// **************************************************************************
|
||||
|
||||
@generatedSerializable
|
||||
class Todo extends _Todo {
|
||||
Todo({this.id, this.text, this.isComplete, this.createdAt, this.updatedAt});
|
||||
|
||||
@override
|
||||
final String? id;
|
||||
|
||||
@override
|
||||
final String? text;
|
||||
|
||||
@override
|
||||
final bool? isComplete;
|
||||
|
||||
@override
|
||||
final DateTime? createdAt;
|
||||
|
||||
@override
|
||||
final DateTime? updatedAt;
|
||||
|
||||
Todo copyWith(
|
||||
{String? id,
|
||||
String? text,
|
||||
bool? isComplete,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt}) {
|
||||
return Todo(
|
||||
id: id ?? this.id,
|
||||
text: text ?? this.text,
|
||||
isComplete: isComplete ?? this.isComplete,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Todo &&
|
||||
other.id == id &&
|
||||
other.text == text &&
|
||||
other.isComplete == isComplete &&
|
||||
other.createdAt == createdAt &&
|
||||
other.updatedAt == updatedAt;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return hashObjects([id, text, isComplete, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Todo(id=$id, text=$text, isComplete=$isComplete, createdAt=$createdAt, updatedAt=$updatedAt)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return TodoSerializer.toMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
const TodoSerializer todoSerializer = TodoSerializer();
|
||||
|
||||
class TodoEncoder extends Converter<Todo, Map> {
|
||||
const TodoEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Todo model) => TodoSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class TodoDecoder extends Converter<Map, Todo> {
|
||||
const TodoDecoder();
|
||||
|
||||
@override
|
||||
Todo convert(Map map) => TodoSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class TodoSerializer extends Codec<Todo, Map> {
|
||||
const TodoSerializer();
|
||||
|
||||
@override
|
||||
TodoEncoder get encoder => const TodoEncoder();
|
||||
@override
|
||||
TodoDecoder get decoder => const TodoDecoder();
|
||||
static Todo fromMap(Map map) {
|
||||
return Todo(
|
||||
id: map['id'] as String?,
|
||||
text: map['text'] as String?,
|
||||
isComplete: map['is_complete'] as bool?,
|
||||
createdAt: map['created_at'] != null
|
||||
? (map['created_at'] is DateTime
|
||||
? (map['created_at'] as DateTime?)
|
||||
: DateTime.parse(map['created_at'].toString()))
|
||||
: null,
|
||||
updatedAt: map['updated_at'] != null
|
||||
? (map['updated_at'] is DateTime
|
||||
? (map['updated_at'] as DateTime?)
|
||||
: DateTime.parse(map['updated_at'].toString()))
|
||||
: null);
|
||||
}
|
||||
|
||||
static Map<String, dynamic> toMap(_Todo model) {
|
||||
return {
|
||||
'id': model.id,
|
||||
'text': model.text,
|
||||
'is_complete': model.isComplete,
|
||||
'created_at': model.createdAt?.toIso8601String(),
|
||||
'updated_at': model.updatedAt?.toIso8601String()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TodoFields {
|
||||
static const List<String> allFields = <String>[
|
||||
id,
|
||||
text,
|
||||
isComplete,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String text = 'text';
|
||||
|
||||
static const String isComplete = 'is_complete';
|
||||
|
||||
static const String createdAt = 'created_at';
|
||||
|
||||
static const String updatedAt = 'updated_at';
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// _GraphQLGenerator
|
||||
// **************************************************************************
|
||||
|
||||
/// Auto-generated from [Todo].
|
||||
final GraphQLObjectType todoGraphQLType =
|
||||
objectType('Todo', isInterface: false, interfaces: [], fields: [
|
||||
field('id', graphQLString),
|
||||
field('text', graphQLString),
|
||||
field('is_complete', graphQLBoolean),
|
||||
field('created_at', graphQLDate),
|
||||
field('updated_at', graphQLDate),
|
||||
field('idAsInt', graphQLInt)
|
||||
]);
|
20
lib/src/routes/graphql/graphql.dart
Normal file
20
lib/src/routes/graphql/graphql.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_graphql/angel3_graphql.dart';
|
||||
import 'package:graphql_server2/graphql_server2.dart';
|
||||
import 'schema.dart';
|
||||
|
||||
/// Configures the [app] to server GraphQL.
|
||||
void configureServer(Angel app) {
|
||||
// Create a [GraphQL] service instance, using our schema.
|
||||
var schema = createSchema(app);
|
||||
var graphQL = GraphQL(schema);
|
||||
|
||||
// Mount a handler that responds to GraphQL queries.
|
||||
app.all('/graphql', graphQLHttp(graphQL));
|
||||
|
||||
// In development, serve the GraphiQL IDE/editor.
|
||||
// More info: https://github.com/graphql/graphiql
|
||||
if (!app.environment.isProduction) {
|
||||
app.get('/graphiql', graphiQL());
|
||||
}
|
||||
}
|
22
lib/src/routes/graphql/schema.dart
Normal file
22
lib/src/routes/graphql/schema.dart
Normal file
|
@ -0,0 +1,22 @@
|
|||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:graphql_schema2/graphql_schema2.dart';
|
||||
import 'todo.dart';
|
||||
|
||||
/// Creates a GraphQL schema that manages an in-memory store of
|
||||
/// Todo items.
|
||||
GraphQLSchema createSchema(Angel app) {
|
||||
var queryType = objectType(
|
||||
'TodoQuery',
|
||||
fields: todoQueryFields(app),
|
||||
);
|
||||
|
||||
var mutationType = objectType(
|
||||
'TodoMutation',
|
||||
fields: todoMutationFields(app),
|
||||
);
|
||||
|
||||
return graphQLSchema(
|
||||
queryType: queryType,
|
||||
mutationType: mutationType,
|
||||
);
|
||||
}
|
73
lib/src/routes/graphql/todo.dart
Normal file
73
lib/src/routes/graphql/todo.dart
Normal file
|
@ -0,0 +1,73 @@
|
|||
import 'package:angel/src/models/todo.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_graphql/angel3_graphql.dart';
|
||||
import 'package:graphql_schema2/graphql_schema2.dart';
|
||||
|
||||
/// Find or create an in-memory Todo store.
|
||||
MapService? _getTodoService(Angel app) {
|
||||
const key = 'todoService';
|
||||
|
||||
// If there is already an existing singleton, return it.
|
||||
if (app.container.hasNamed(key)) {
|
||||
return app.container.findByName<MapService>(key);
|
||||
}
|
||||
|
||||
// Create an in-memory service. We will use this
|
||||
// as the backend to store Todo objects, serialized to Maps.
|
||||
var mapService = MapService();
|
||||
|
||||
// Register this service as a named singleton in the app container,
|
||||
// so that we do not inadvertently create another instance.
|
||||
app.container.registerNamedSingleton(key, mapService);
|
||||
|
||||
return mapService;
|
||||
}
|
||||
|
||||
/// Returns fields to be inserted into the query type.
|
||||
Iterable<GraphQLObjectField> todoQueryFields(Angel app) {
|
||||
var todoService = _getTodoService(app)!;
|
||||
|
||||
// Here, we use special resolvers to read data from our store.
|
||||
return [
|
||||
field(
|
||||
'todos',
|
||||
listOf(todoGraphQLType),
|
||||
resolve: resolveViaServiceIndex(todoService),
|
||||
),
|
||||
field(
|
||||
'todo',
|
||||
todoGraphQLType,
|
||||
resolve: resolveViaServiceRead(todoService),
|
||||
inputs: [
|
||||
GraphQLFieldInput('id', graphQLString.nonNullable()),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/// Returns fields to be inserted into the query type.
|
||||
Iterable<GraphQLObjectField> todoMutationFields(Angel app) {
|
||||
var todoService = _getTodoService(app)!;
|
||||
var todoInputType = todoGraphQLType.toInputObject('TodoInput');
|
||||
|
||||
// This time, we use resolvers to modify the data in the store.
|
||||
return [
|
||||
field(
|
||||
'createTodo',
|
||||
todoGraphQLType,
|
||||
resolve: resolveViaServiceCreate(todoService),
|
||||
inputs: [
|
||||
GraphQLFieldInput('data', todoInputType.nonNullable()),
|
||||
],
|
||||
),
|
||||
field(
|
||||
'modifyTodo',
|
||||
todoGraphQLType,
|
||||
resolve: resolveViaServiceModify(todoService),
|
||||
inputs: [
|
||||
GraphQLFieldInput('id', graphQLString.nonNullable()),
|
||||
GraphQLFieldInput('data', todoInputType.nonNullable()),
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/// This app's route configuration.
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_static/angel3_static.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'controllers/controllers.dart' as controllers;
|
||||
import 'graphql/graphql.dart' as graphql;
|
||||
|
||||
/// Put your app routes here!
|
||||
///
|
||||
|
@ -14,6 +14,9 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
|
|||
// Typically, you want to mount controllers first, after any global middleware.
|
||||
await app.configure(controllers.configureServer);
|
||||
|
||||
// Mount our GraphQL routes as well.
|
||||
await app.configure(graphql.configureServer);
|
||||
|
||||
// Render `views/hello.jl` when a user visits the application root.
|
||||
app.get('/', (req, res) => res.render('hello'));
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/// Declare services here!
|
||||
import 'dart:async';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
|
||||
|
|
37
pubspec.yaml
37
pubspec.yaml
|
@ -1,25 +1,24 @@
|
|||
name: angel
|
||||
version: 1.0.0
|
||||
description: A basic starter application template for Angel3 framework
|
||||
publish_to: none
|
||||
description: A graphql starter application for Angel3 framework
|
||||
publish_to: none
|
||||
environment:
|
||||
sdk: '>=2.16.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_auth: ^6.0.0
|
||||
angel3_configuration: ^6.0.0
|
||||
angel3_framework: ^6.0.0
|
||||
angel3_jael: ^6.0.0
|
||||
angel3_production: ^6.0.0
|
||||
angel3_static: ^6.0.0
|
||||
angel3_validate: ^6.0.0
|
||||
belatuk_pretty_logging: ^4.0.0
|
||||
angel3_auth: ^7.0.0
|
||||
angel3_configuration: ^7.0.0
|
||||
angel3_framework: ^7.0.0
|
||||
angel3_graphql: ^7.0.0
|
||||
angel3_jael: ^7.0.0
|
||||
angel3_production: ^7.0.0
|
||||
angel3_static: ^7.0.0
|
||||
angel3_validate: ^7.0.0
|
||||
dev_dependencies:
|
||||
angel3_hot: ^6.0.0
|
||||
angel3_test: ^6.0.0
|
||||
io: ^1.0.0
|
||||
angel3_hot: ^7.0.0
|
||||
angel3_serialize_generator: ^7.0.0
|
||||
angel3_test: ^7.0.0
|
||||
graphql_generator2: ^5.0.0
|
||||
belatuk_pretty_logging: ^5.0.0
|
||||
build_runner: ^2.0.4
|
||||
io: ^1.0.0
|
||||
test: ^1.21.0
|
||||
lints: ^1.0.0
|
||||
|
||||
|
||||
|
||||
|
||||
lints: ^2.0.0
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:angel/angel.dart';
|
||||
import 'package:angel3_framework/angel3_framework.dart';
|
||||
import 'package:angel3_test/angel3_test.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:angel/angel.dart';
|
||||
|
||||
// Angel also includes facilities to make testing easier.
|
||||
//
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<extend src="layout.jael">
|
||||
<block name="content">
|
||||
<div class="title">Angel</div>
|
||||
<p>
|
||||
<a href="/graphiql">Click here</a> to access GraphiQL.
|
||||
</p>
|
||||
</block>
|
||||
</extend>
|
|
@ -11,6 +11,16 @@ body {
|
|||
font-family: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(8, 114, 175) !important;
|
||||
font-weight: 900;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
display: table-cell;
|
||||
|
|
Loading…
Reference in a new issue