Non-nullable types MUST be present in validate

This commit is contained in:
Tobe O 2018-08-03 17:38:20 -04:00
parent f4a3bb22d3
commit f43c6036eb
10 changed files with 27 additions and 132 deletions

View file

@ -4,7 +4,6 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/angel_graphql/angel_graphql.iml" filepath="$PROJECT_DIR$/angel_graphql/angel_graphql.iml" />
<module fileurl="file://$PROJECT_DIR$/graphql.iml" filepath="$PROJECT_DIR$/graphql.iml" />
<module fileurl="file://$PROJECT_DIR$/graphql_generator/graphql_generator.iml" filepath="$PROJECT_DIR$/graphql_generator/graphql_generator.iml" />
<module fileurl="file://$PROJECT_DIR$/graphql_parser/graphql_parser.iml" filepath="$PROJECT_DIR$/graphql_parser/graphql_parser.iml" />
<module fileurl="file://$PROJECT_DIR$/graphql_schema/graphql_schema.iml" filepath="$PROJECT_DIR$/graphql_schema/graphql_schema.iml" />
<module fileurl="file://$PROJECT_DIR$/graphql_server/graphql_server.iml" filepath="$PROJECT_DIR$/graphql_server/graphql_server.iml" />

View file

@ -1,4 +1,6 @@
name: angel_graphql
environment:
sdk: ">=1.8.0 <3.0.0"
dependencies:
angel_framework: ^1.0.0
angel_validate: ^1.0.0

View file

@ -1,93 +0,0 @@
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
.buildlog
.packages
.project
.pub/
.scripts-bin/
build/
**/packages/
# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
*.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json
# Directory created by dartdoc
doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
# SDK 1.20 and later (no longer creates packages directories)
# Older SDK versions
# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20)
# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
# Directory created by dartdoc
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
../.idea/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.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
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2017 The Angel Framework
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,3 +0,0 @@
analyzer:
strong-mode:
implicit-casts: false

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -20,6 +20,14 @@ class GraphQLObjectType
var out = {};
List<String> errors = [];
for (var field in fields) {
if (field.type is GraphQLNonNullableType) {
if (!input.containsKey(field.name) || input[field.name] == null) {
errors.add('Field "${field.name}, of type ${field.type} cannot be null."');
}
}
}
input.keys.forEach((k) {
var field = fields.firstWhere((f) => f.name == k, orElse: () => null);

View file

@ -12,6 +12,9 @@ abstract class GraphQLType<Value, Serialized> {
ValidationResult<Serialized> validate(String key, Serialized input);
GraphQLType<Value, Serialized> nonNullable();
@override
String toString() => name;
}
/// Shorthand to create a [GraphQLListType].
@ -65,6 +68,9 @@ class GraphQLListType<Value, Serialized>
List<Serialized> serialize(List<Value> value) {
return value.map<Serialized>(innerType.serialize).toList();
}
@override
String toString() => '[$innerType]';
}
abstract class _NonNullableMixin<Value, Serialized>
@ -111,4 +117,9 @@ class GraphQLNonNullableType<Value, Serialized>
Serialized serialize(Value value) {
return innerType.serialize(value);
}
@override
String toString() {
return '$innerType!';
}
}

View file

@ -1,4 +1,6 @@
name: graphql_server
environment:
sdk: ">=1.8.0 <3.0.0"
dependencies:
angel_serialize: ^2.0.0
graphql_schema:

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash
cd graphql_parser && pub get && pub run test -j2 && cd ..
cd graphql_schema && pub get && pub run test -j2 && cd ..
cd graphql_server && pub get && pub run test -j2 && cd ..
PWD=$(pwd)
cd "$PWD/graphql_parser" && pub get && pub run test -j2 && cd ..
cd "$PWD/graphql_schema" && pub get && pub run test -j2 && cd ..
cd "$PWD/graphql_server" && pub get && pub run test -j2 && cd ..