Ignore tokens named in spec

This commit is contained in:
Tobe O 2018-08-04 15:41:40 -04:00
parent 2256b2afdb
commit 532f698aa2
2 changed files with 18 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import 'package:string_scanner/string_scanner.dart';
import 'syntax_error.dart';
import 'token.dart';
import 'token_type.dart';
@ -45,7 +46,10 @@ List<Token> scan(String text, {sourceUrl}) {
while (!scanner.isDone) {
List<Token> potential = [];
if (scanner.scan(_comment) || scanner.scan(_whitespace)) continue;
if (scanner.scan(_comment) ||
scanner.scan(_whitespace) ||
scanner.scan(',') ||
scanner.scan('\ufeff')) continue;
for (var pattern in _patterns.keys) {
if (scanner.matches(pattern)) {

View file

@ -215,12 +215,19 @@ class GraphQL {
for (var field in fields) {
var fieldName = field.field.fieldName.name;
var responseValue;
if (fieldName == '__typename') {
responseValue = objectType.name;
} else {
var fieldType = objectType.fields
.firstWhere((f) => f.name == fieldName, orElse: () => null)
?.type;
if (fieldType == null) continue;
var responseValue = await executeField(document, fieldName, objectType,
responseValue = await executeField(document, fieldName, objectType,
objectValue, fields, fieldType, variableValues);
}
resultMap[responseKey] = responseValue;
}
}