Remove "new" kw
This commit is contained in:
parent
1d33583ddf
commit
cf4b96da42
5 changed files with 56 additions and 56 deletions
|
@ -23,7 +23,7 @@ void main() {
|
||||||
'todos',
|
'todos',
|
||||||
listOf(todoType),
|
listOf(todoType),
|
||||||
resolve: (_, __) => [
|
resolve: (_, __) => [
|
||||||
new Todo(
|
Todo(
|
||||||
text: 'Clean your room!',
|
text: 'Clean your room!',
|
||||||
completed: false,
|
completed: false,
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ void main() {
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
var graphql = new GraphQL(schema);
|
var graphql = GraphQL(schema);
|
||||||
var result = await graphql.parseAndExecute('{ todos { text } }');
|
var result = await graphql.parseAndExecute('{ todos { text } }');
|
||||||
|
|
||||||
print(result);
|
print(result);
|
||||||
|
|
|
@ -53,7 +53,7 @@ class GraphQL {
|
||||||
|
|
||||||
GraphQLType convertType(TypeContext ctx) {
|
GraphQLType convertType(TypeContext ctx) {
|
||||||
if (ctx.listType != null) {
|
if (ctx.listType != null) {
|
||||||
return new GraphQLListType(convertType(ctx.listType.type));
|
return GraphQLListType(convertType(ctx.listType.type));
|
||||||
} else if (ctx.typeName != null) {
|
} else if (ctx.typeName != null) {
|
||||||
switch (ctx.typeName.name) {
|
switch (ctx.typeName.name) {
|
||||||
case 'Int':
|
case 'Int':
|
||||||
|
@ -71,11 +71,11 @@ class GraphQL {
|
||||||
return graphQLDate;
|
return graphQLDate;
|
||||||
default:
|
default:
|
||||||
return customTypes.firstWhere((t) => t.name == ctx.typeName.name,
|
return customTypes.firstWhere((t) => t.name == ctx.typeName.name,
|
||||||
orElse: () => throw new ArgumentError(
|
orElse: () => throw ArgumentError(
|
||||||
'Unknown GraphQL type: "${ctx.typeName.name}"'));
|
'Unknown GraphQL type: "${ctx.typeName.name}"'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentError('Invalid GraphQL type: "${ctx.span.text}"');
|
throw ArgumentError('Invalid GraphQL type: "${ctx.span.text}"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ class GraphQL {
|
||||||
initialValue,
|
initialValue,
|
||||||
Map<String, dynamic> globalVariables}) {
|
Map<String, dynamic> globalVariables}) {
|
||||||
var tokens = scan(text, sourceUrl: sourceUrl);
|
var tokens = scan(text, sourceUrl: sourceUrl);
|
||||||
var parser = new Parser(tokens);
|
var parser = Parser(tokens);
|
||||||
var document = parser.parseDocument();
|
var document = parser.parseDocument();
|
||||||
|
|
||||||
if (parser.errors.isNotEmpty) {
|
if (parser.errors.isNotEmpty) {
|
||||||
throw new GraphQLException(parser.errors
|
throw GraphQLException(parser.errors
|
||||||
.map((e) => new GraphQLExceptionError(e.message, locations: [
|
.map((e) => GraphQLExceptionError(e.message, locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(e.span.start)
|
GraphExceptionErrorLocation.fromSourceLocation(e.span.start)
|
||||||
]))
|
]))
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ class GraphQL {
|
||||||
if (operationName == null) {
|
if (operationName == null) {
|
||||||
return ops.length == 1
|
return ops.length == 1
|
||||||
? ops.first as OperationDefinitionContext
|
? ops.first as OperationDefinitionContext
|
||||||
: throw new GraphQLException.fromMessage(
|
: throw GraphQLException.fromMessage(
|
||||||
'This document does not define any operations.');
|
'This document does not define any operations.');
|
||||||
} else {
|
} else {
|
||||||
return ops.firstWhere(
|
return ops.firstWhere(
|
||||||
(d) => (d as OperationDefinitionContext).name == operationName,
|
(d) => (d as OperationDefinitionContext).name == operationName,
|
||||||
orElse: () => throw new GraphQLException.fromMessage(
|
orElse: () => throw GraphQLException.fromMessage(
|
||||||
'Missing required operation "$operationName".'))
|
'Missing required operation "$operationName".'))
|
||||||
as OperationDefinitionContext;
|
as OperationDefinitionContext;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ class GraphQL {
|
||||||
if (defaultValue != null) {
|
if (defaultValue != null) {
|
||||||
coercedValues[variableName] = defaultValue.value.value;
|
coercedValues[variableName] = defaultValue.value.value;
|
||||||
} else if (!variableType.isNullable) {
|
} else if (!variableType.isNullable) {
|
||||||
throw new GraphQLException.fromSourceSpan(
|
throw GraphQLException.fromSourceSpan(
|
||||||
'Missing required variable "$variableName".',
|
'Missing required variable "$variableName".',
|
||||||
variableDefinition.span);
|
variableDefinition.span);
|
||||||
}
|
}
|
||||||
|
@ -173,9 +173,9 @@ class GraphQL {
|
||||||
var validation = type.validate(variableName, value);
|
var validation = type.validate(variableName, value);
|
||||||
|
|
||||||
if (!validation.successful) {
|
if (!validation.successful) {
|
||||||
throw new GraphQLException(validation.errors
|
throw GraphQLException(validation.errors
|
||||||
.map((e) => new GraphQLExceptionError(e, locations: [
|
.map((e) => GraphQLExceptionError(e, locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(
|
GraphExceptionErrorLocation.fromSourceLocation(
|
||||||
variableDefinition.span.start)
|
variableDefinition.span.start)
|
||||||
]))
|
]))
|
||||||
.toList());
|
.toList());
|
||||||
|
@ -211,7 +211,7 @@ class GraphQL {
|
||||||
var mutationType = schema.mutationType;
|
var mutationType = schema.mutationType;
|
||||||
|
|
||||||
if (mutationType == null) {
|
if (mutationType == null) {
|
||||||
throw new GraphQLException.fromMessage(
|
throw GraphQLException.fromMessage(
|
||||||
'The schema does not define a mutation type.');
|
'The schema does not define a mutation type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ class GraphQL {
|
||||||
objectValue,
|
objectValue,
|
||||||
fields,
|
fields,
|
||||||
fieldType,
|
fieldType,
|
||||||
new Map<String, dynamic>.from(
|
Map<String, dynamic>.from(
|
||||||
globalVariables ?? <String, dynamic>{})
|
globalVariables ?? <String, dynamic>{})
|
||||||
..addAll(variableValues),
|
..addAll(variableValues),
|
||||||
globalVariables);
|
globalVariables);
|
||||||
|
@ -411,7 +411,7 @@ class GraphQL {
|
||||||
} else if (defaultValue != null || argumentDefinition.defaultsToNull) {
|
} else if (defaultValue != null || argumentDefinition.defaultsToNull) {
|
||||||
coercedValues[argumentName] = defaultValue;
|
coercedValues[argumentName] = defaultValue;
|
||||||
} else if (argumentType is GraphQLNonNullableType) {
|
} else if (argumentType is GraphQLNonNullableType) {
|
||||||
throw new GraphQLException.fromSourceSpan(
|
throw GraphQLException.fromSourceSpan(
|
||||||
'Missing value for argument "$argumentName" of field "$fieldName".',
|
'Missing value for argument "$argumentName" of field "$fieldName".',
|
||||||
value.valueOrVariable.span);
|
value.valueOrVariable.span);
|
||||||
} else {
|
} else {
|
||||||
|
@ -421,7 +421,7 @@ class GraphQL {
|
||||||
if (defaultValue != null || argumentDefinition.defaultsToNull) {
|
if (defaultValue != null || argumentDefinition.defaultsToNull) {
|
||||||
coercedValues[argumentName] = defaultValue;
|
coercedValues[argumentName] = defaultValue;
|
||||||
} else if (argumentType is GraphQLNonNullableType) {
|
} else if (argumentType is GraphQLNonNullableType) {
|
||||||
throw new GraphQLException.fromMessage(
|
throw GraphQLException.fromMessage(
|
||||||
'Missing value for argument "$argumentName" of field "$fieldName".');
|
'Missing value for argument "$argumentName" of field "$fieldName".');
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -433,10 +433,10 @@ class GraphQL {
|
||||||
|
|
||||||
if (!validation.successful) {
|
if (!validation.successful) {
|
||||||
var errors = <GraphQLExceptionError>[
|
var errors = <GraphQLExceptionError>[
|
||||||
new GraphQLExceptionError(
|
GraphQLExceptionError(
|
||||||
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
|
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
|
||||||
locations: [
|
locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(
|
GraphExceptionErrorLocation.fromSourceLocation(
|
||||||
value.valueOrVariable.span.start)
|
value.valueOrVariable.span.start)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -444,34 +444,34 @@ class GraphQL {
|
||||||
|
|
||||||
for (var error in validation.errors) {
|
for (var error in validation.errors) {
|
||||||
errors.add(
|
errors.add(
|
||||||
new GraphQLExceptionError(
|
GraphQLExceptionError(
|
||||||
error,
|
error,
|
||||||
locations: [
|
locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(
|
GraphExceptionErrorLocation.fromSourceLocation(
|
||||||
value.valueOrVariable.span.start)
|
value.valueOrVariable.span.start)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new GraphQLException(errors);
|
throw GraphQLException(errors);
|
||||||
} else {
|
} else {
|
||||||
var coercedValue = validation.value;
|
var coercedValue = validation.value;
|
||||||
coercedValues[argumentName] = coercedValue;
|
coercedValues[argumentName] = coercedValue;
|
||||||
}
|
}
|
||||||
} on TypeError catch (e) {
|
} on TypeError catch (e) {
|
||||||
throw new GraphQLException(<GraphQLExceptionError>[
|
throw GraphQLException(<GraphQLExceptionError>[
|
||||||
new GraphQLExceptionError(
|
GraphQLExceptionError(
|
||||||
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
|
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
|
||||||
locations: [
|
locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(
|
GraphExceptionErrorLocation.fromSourceLocation(
|
||||||
value.valueOrVariable.span.start)
|
value.valueOrVariable.span.start)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
new GraphQLExceptionError(
|
GraphQLExceptionError(
|
||||||
e.message.toString(),
|
e.message.toString(),
|
||||||
locations: [
|
locations: [
|
||||||
new GraphExceptionErrorLocation.fromSourceLocation(
|
GraphExceptionErrorLocation.fromSourceLocation(
|
||||||
value.valueOrVariable.span.start)
|
value.valueOrVariable.span.start)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -514,7 +514,7 @@ class GraphQL {
|
||||||
fields, result, variableValues, globalVariables);
|
fields, result, variableValues, globalVariables);
|
||||||
|
|
||||||
if (completedResult == null) {
|
if (completedResult == null) {
|
||||||
throw new GraphQLException.fromMessage(
|
throw GraphQLException.fromMessage(
|
||||||
'Null value provided for non-nullable field "$fieldName".');
|
'Null value provided for non-nullable field "$fieldName".');
|
||||||
} else {
|
} else {
|
||||||
return completedResult;
|
return completedResult;
|
||||||
|
@ -527,7 +527,7 @@ class GraphQL {
|
||||||
|
|
||||||
if (fieldType is GraphQLListType) {
|
if (fieldType is GraphQLListType) {
|
||||||
if (result is! Iterable) {
|
if (result is! Iterable) {
|
||||||
throw new GraphQLException.fromMessage(
|
throw GraphQLException.fromMessage(
|
||||||
'Value of field "$fieldName" must be a list or iterable, got $result instead.');
|
'Value of field "$fieldName" must be a list or iterable, got $result instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ class GraphQL {
|
||||||
return validation.value;
|
return validation.value;
|
||||||
}
|
}
|
||||||
} on TypeError {
|
} on TypeError {
|
||||||
throw new GraphQLException.fromMessage(
|
throw GraphQLException.fromMessage(
|
||||||
'Value of field "$fieldName" must be ${fieldType.valueType}, got $result instead.');
|
'Value of field "$fieldName" must be ${fieldType.valueType}, got $result instead.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ class GraphQL {
|
||||||
result, variableValues, globalVariables);
|
result, variableValues, globalVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedError('Unsupported type: $fieldType');
|
throw UnsupportedError('Unsupported type: $fieldType');
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphQLObjectType resolveAbstractType(
|
GraphQLObjectType resolveAbstractType(
|
||||||
|
@ -587,7 +587,7 @@ class GraphQL {
|
||||||
} else if (type is GraphQLUnionType) {
|
} else if (type is GraphQLUnionType) {
|
||||||
possibleTypes = type.possibleTypes;
|
possibleTypes = type.possibleTypes;
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentError();
|
throw ArgumentError();
|
||||||
}
|
}
|
||||||
|
|
||||||
var errors = <GraphQLExceptionError>[];
|
var errors = <GraphQLExceptionError>[];
|
||||||
|
@ -602,7 +602,7 @@ class GraphQL {
|
||||||
}
|
}
|
||||||
|
|
||||||
errors
|
errors
|
||||||
.addAll(validation.errors.map((m) => new GraphQLExceptionError(m)));
|
.addAll(validation.errors.map((m) => GraphQLExceptionError(m)));
|
||||||
} on GraphQLException catch (e) {
|
} on GraphQLException catch (e) {
|
||||||
errors.addAll(e.errors);
|
errors.addAll(e.errors);
|
||||||
}
|
}
|
||||||
|
@ -610,10 +610,10 @@ class GraphQL {
|
||||||
|
|
||||||
errors.insert(
|
errors.insert(
|
||||||
0,
|
0,
|
||||||
new GraphQLExceptionError(
|
GraphQLExceptionError(
|
||||||
'Cannot convert value $result to type $type.'));
|
'Cannot convert value $result to type $type.'));
|
||||||
|
|
||||||
throw new GraphQLException(errors);
|
throw GraphQLException(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectionSetContext mergeSelectionSets(List<SelectionContext> fields) {
|
SelectionSetContext mergeSelectionSets(List<SelectionContext> fields) {
|
||||||
|
@ -627,7 +627,7 @@ class GraphQL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SelectionSetContext.merged(selections);
|
return SelectionSetContext.merged(selections);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<SelectionContext>> collectFields(
|
Map<String, List<SelectionContext>> collectFields(
|
||||||
|
@ -713,7 +713,7 @@ class GraphQL {
|
||||||
|
|
||||||
var vname = vv.variable.name;
|
var vname = vv.variable.name;
|
||||||
if (!variableValues.containsKey(vname))
|
if (!variableValues.containsKey(vname))
|
||||||
throw new GraphQLException.fromSourceSpan(
|
throw GraphQLException.fromSourceSpan(
|
||||||
'Unknown variable: "$vname"', vv.span);
|
'Unknown variable: "$vname"', vv.span);
|
||||||
|
|
||||||
return variableValues[vname];
|
return variableValues[vname];
|
||||||
|
@ -721,7 +721,7 @@ class GraphQL {
|
||||||
|
|
||||||
bool doesFragmentTypeApply(
|
bool doesFragmentTypeApply(
|
||||||
GraphQLObjectType objectType, TypeConditionContext fragmentType) {
|
GraphQLObjectType objectType, TypeConditionContext fragmentType) {
|
||||||
var type = convertType(new TypeContext(fragmentType.typeName, null));
|
var type = convertType(TypeContext(fragmentType.typeName, null));
|
||||||
if (type is GraphQLObjectType && !type.isInterface) {
|
if (type is GraphQLObjectType && !type.isInterface) {
|
||||||
for (var field in type.fields)
|
for (var field in type.fields)
|
||||||
if (!objectType.fields.any((f) => f.name == field.name)) return false;
|
if (!objectType.fields.any((f) => f.name == field.name)) return false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:graphql_parser/graphql_parser.dart';
|
import 'package:graphql_parser/graphql_parser.dart';
|
||||||
import 'package:graphql_schema/graphql_schema.dart';
|
import 'package:graphql_schema/graphql_schema.dart';
|
||||||
|
|
||||||
/// Performs introspection over a GraphQL [schema], and returns a new one, containing
|
/// Performs introspection over a GraphQL [schema], and returns a one, containing
|
||||||
/// introspective information.
|
/// introspective information.
|
||||||
///
|
///
|
||||||
/// [allTypes] should contain all types, not directly defined in the schema, that you
|
/// [allTypes] should contain all types, not directly defined in the schema, that you
|
||||||
|
@ -79,11 +79,11 @@ GraphQLSchema reflectSchema(GraphQLSchema schema, List<GraphQLType> allTypes) {
|
||||||
field(
|
field(
|
||||||
'__type',
|
'__type',
|
||||||
typeType,
|
typeType,
|
||||||
inputs: [new GraphQLFieldInput('name', graphQLString.nonNullable())],
|
inputs: [GraphQLFieldInput('name', graphQLString.nonNullable())],
|
||||||
resolve: (_, args) {
|
resolve: (_, args) {
|
||||||
var name = args['name'] as String;
|
var name = args['name'] as String;
|
||||||
return allTypes.firstWhere((t) => t.name == name,
|
return allTypes.firstWhere((t) => t.name == name,
|
||||||
orElse: () => throw new GraphQLException.fromMessage(
|
orElse: () => throw GraphQLException.fromMessage(
|
||||||
'No type named "$name" exists.'));
|
'No type named "$name" exists.'));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -91,7 +91,7 @@ GraphQLSchema reflectSchema(GraphQLSchema schema, List<GraphQLType> allTypes) {
|
||||||
|
|
||||||
fields.addAll(schema.queryType.fields);
|
fields.addAll(schema.queryType.fields);
|
||||||
|
|
||||||
return new GraphQLSchema(
|
return GraphQLSchema(
|
||||||
queryType: objectType(schema.queryType.name, fields: fields),
|
queryType: objectType(schema.queryType.name, fields: fields),
|
||||||
mutationType: schema.mutationType,
|
mutationType: schema.mutationType,
|
||||||
subscriptionType: schema.subscriptionType,
|
subscriptionType: schema.subscriptionType,
|
||||||
|
@ -228,14 +228,14 @@ GraphQLObjectType _createTypeType() {
|
||||||
else if (t is GraphQLUnionType)
|
else if (t is GraphQLUnionType)
|
||||||
return 'UNION';
|
return 'UNION';
|
||||||
else
|
else
|
||||||
throw new UnsupportedError('Cannot get the kind of $t.');
|
throw UnsupportedError('Cannot get the kind of $t.');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
field(
|
field(
|
||||||
'fields',
|
'fields',
|
||||||
listOf(fieldType),
|
listOf(fieldType),
|
||||||
inputs: [
|
inputs: [
|
||||||
new GraphQLFieldInput(
|
GraphQLFieldInput(
|
||||||
'includeDeprecated',
|
'includeDeprecated',
|
||||||
graphQLBoolean,
|
graphQLBoolean,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
@ -252,7 +252,7 @@ GraphQLObjectType _createTypeType() {
|
||||||
'enumValues',
|
'enumValues',
|
||||||
listOf(enumValueType.nonNullable()),
|
listOf(enumValueType.nonNullable()),
|
||||||
inputs: [
|
inputs: [
|
||||||
new GraphQLFieldInput(
|
GraphQLFieldInput(
|
||||||
'includeDeprecated',
|
'includeDeprecated',
|
||||||
graphQLBoolean,
|
graphQLBoolean,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
|
|
@ -42,10 +42,10 @@ GraphQLType _objectTypeFromDartType(Type type, [List<Type> typeArguments]) {
|
||||||
} else if (type == double) {
|
} else if (type == double) {
|
||||||
return graphQLFloat;
|
return graphQLFloat;
|
||||||
} else if (type == num) {
|
} else if (type == num) {
|
||||||
throw new UnsupportedError(
|
throw UnsupportedError(
|
||||||
'Cannot convert `num` to a GraphQL type. Choose `int` or `float` instead.');
|
'Cannot convert `num` to a GraphQL type. Choose `int` or `float` instead.');
|
||||||
} else if (type == Null) {
|
} else if (type == Null) {
|
||||||
throw new UnsupportedError('Cannot convert `Null` to a GraphQL type.');
|
throw UnsupportedError('Cannot convert `Null` to a GraphQL type.');
|
||||||
} else if (type == String) {
|
} else if (type == String) {
|
||||||
return graphQLString;
|
return graphQLString;
|
||||||
} else if (type == DateTime) {
|
} else if (type == DateTime) {
|
||||||
|
@ -56,7 +56,7 @@ GraphQLType _objectTypeFromDartType(Type type, [List<Type> typeArguments]) {
|
||||||
type, typeArguments?.isNotEmpty == true ? typeArguments : null);
|
type, typeArguments?.isNotEmpty == true ? typeArguments : null);
|
||||||
|
|
||||||
if (mirror is! ClassMirror) {
|
if (mirror is! ClassMirror) {
|
||||||
throw new StateError(
|
throw StateError(
|
||||||
'$type is not a class, and therefore cannot be converted into a GraphQL object type.');
|
'$type is not a class, and therefore cannot be converted into a GraphQL object type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ GraphQLType _objectTypeFromDartType(Type type, [List<Type> typeArguments]) {
|
||||||
return listOf(inner.nonNullable());
|
return listOf(inner.nonNullable());
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentError(
|
throw ArgumentError(
|
||||||
'Cannot convert ${clazz.reflectedType}, an iterable WITHOUT a type argument, into a GraphQL type.');
|
'Cannot convert ${clazz.reflectedType}, an iterable WITHOUT a type argument, into a GraphQL type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ GraphQLEnumType enumTypeFromClassMirror(ClassMirror mirror) {
|
||||||
if (name != #values) {
|
if (name != #values) {
|
||||||
var methodMirror = mirror.staticMembers[name];
|
var methodMirror = mirror.staticMembers[name];
|
||||||
values.add(
|
values.add(
|
||||||
new GraphQLEnumValue(
|
GraphQLEnumValue(
|
||||||
MirrorSystem.getName(name),
|
MirrorSystem.getName(name),
|
||||||
mirror.getField(name).reflectee,
|
mirror.getField(name).reflectee,
|
||||||
description: _getDescription(methodMirror.metadata),
|
description: _getDescription(methodMirror.metadata),
|
||||||
|
@ -223,7 +223,7 @@ GraphQLEnumType enumTypeFromClassMirror(ClassMirror mirror) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GraphQLEnumType(
|
return GraphQLEnumType(
|
||||||
MirrorSystem.getName(mirror.simpleName),
|
MirrorSystem.getName(mirror.simpleName),
|
||||||
values,
|
values,
|
||||||
description: _getDescription(mirror.metadata),
|
description: _getDescription(mirror.metadata),
|
||||||
|
@ -294,7 +294,7 @@ String _getSerializedName(Symbol name, MethodMirror mirror, ClassMirror clazz) {
|
||||||
var ann = obj.reflectee as Serializable;
|
var ann = obj.reflectee as Serializable;
|
||||||
|
|
||||||
if (ann.autoSnakeCaseNames != false) {
|
if (ann.autoSnakeCaseNames != false) {
|
||||||
return new ReCase(MirrorSystem.getName(name)).snakeCase;
|
return ReCase(MirrorSystem.getName(name)).snakeCase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ void main() {
|
||||||
'todos',
|
'todos',
|
||||||
listOf(todoType),
|
listOf(todoType),
|
||||||
resolve: (_, __) => [
|
resolve: (_, __) => [
|
||||||
new Todo(
|
Todo(
|
||||||
text: 'Clean your room!',
|
text: 'Clean your room!',
|
||||||
completed: false,
|
completed: false,
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ void main() {
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
var graphql = new GraphQL(schema);
|
var graphql = GraphQL(schema);
|
||||||
var result = await graphql.parseAndExecute('{ todos { text } }');
|
var result = await graphql.parseAndExecute('{ todos { text } }');
|
||||||
|
|
||||||
print(result);
|
print(result);
|
||||||
|
|
Loading…
Reference in a new issue