Corrected introspection of enum types

This commit is contained in:
Tobe O 2018-08-04 11:12:26 -04:00
parent aad1404530
commit 7e0eaa387d
3 changed files with 43 additions and 31 deletions

View file

@ -1,3 +1,7 @@
import 'package:graphql_schema/graphql_schema.dart';
@GraphQLDocumentation(
description: 'The episodes of the Star Wars original trilogy.')
enum Episode {
NEWHOPE,
EMPIRE,

View file

@ -51,6 +51,9 @@ Future configureServer(Angel app) async {
field(
'hero',
type: heroType,
arguments: [
new GraphQLFieldArgument('ep', episodeType),
],
resolve: (_, args) async {
var allHeroes = [];
var allDroids = await droidService.index() as Iterable;
@ -94,18 +97,24 @@ Future configureServer(Angel app) async {
'total_credits': 520,
});
var lando = await humansService.create({
'name': 'Lando Calrissian',
'appears_in': ['EMPIRE', 'JEDI'],
'total_credits': 525430,
});
var hanSolo = await humansService.create({
'name': 'Han Solo',
'appears_in': ['NEWHOPE', 'EMPIRE', 'JEDI'],
'total_credits': 23,
'friends': [leia],
'friends': [leia, lando],
});
var luke = await humansService.create({
'name': 'Luke Skywalker',
'appears_in': ['NEWHOPE', 'EMPIRE', 'JEDI'],
'total_credits': 682,
'friends': [leia, hanSolo],
'friends': [leia, hanSolo, lando],
});
}

View file

@ -207,7 +207,9 @@ GraphQLObjectType _createTypeType() {
resolve: (type, _) {
var t = type as GraphQLType;
if (t is GraphQLScalarType)
if (t is GraphQLEnumType)
return 'ENUM';
else if (t is GraphQLScalarType)
return 'SCALAR';
else if (t is GraphQLObjectType)
return t.isInterface ? 'INTERFACE' : 'OBJECT';
@ -215,8 +217,6 @@ GraphQLObjectType _createTypeType() {
return 'LIST';
else if (t is GraphQLNonNullableType)
return 'NON_NULL';
else if (t is GraphQLEnumType)
return 'ENUM';
else if (t is GraphQLUnionType)
return 'UNION';
else
@ -376,8 +376,7 @@ GraphQLObjectType _reflectDirectiveType() {
GraphQLObjectType _enumValueType;
GraphQLObjectType _reflectEnumValueType() {
return _enumValueType ??
objectType(
return _enumValueType ??= objectType(
'__EnumValue',
fields: [
field(