Ignore tokens named in spec
This commit is contained in:
parent
2256b2afdb
commit
532f698aa2
2 changed files with 18 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:string_scanner/string_scanner.dart';
|
import 'package:string_scanner/string_scanner.dart';
|
||||||
|
|
||||||
import 'syntax_error.dart';
|
import 'syntax_error.dart';
|
||||||
import 'token.dart';
|
import 'token.dart';
|
||||||
import 'token_type.dart';
|
import 'token_type.dart';
|
||||||
|
@ -45,7 +46,10 @@ List<Token> scan(String text, {sourceUrl}) {
|
||||||
while (!scanner.isDone) {
|
while (!scanner.isDone) {
|
||||||
List<Token> potential = [];
|
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) {
|
for (var pattern in _patterns.keys) {
|
||||||
if (scanner.matches(pattern)) {
|
if (scanner.matches(pattern)) {
|
||||||
|
|
|
@ -215,12 +215,19 @@ class GraphQL {
|
||||||
|
|
||||||
for (var field in fields) {
|
for (var field in fields) {
|
||||||
var fieldName = field.field.fieldName.name;
|
var fieldName = field.field.fieldName.name;
|
||||||
|
var responseValue;
|
||||||
|
|
||||||
|
if (fieldName == '__typename') {
|
||||||
|
responseValue = objectType.name;
|
||||||
|
} else {
|
||||||
var fieldType = objectType.fields
|
var fieldType = objectType.fields
|
||||||
.firstWhere((f) => f.name == fieldName, orElse: () => null)
|
.firstWhere((f) => f.name == fieldName, orElse: () => null)
|
||||||
?.type;
|
?.type;
|
||||||
if (fieldType == null) continue;
|
if (fieldType == null) continue;
|
||||||
var responseValue = await executeField(document, fieldName, objectType,
|
responseValue = await executeField(document, fieldName, objectType,
|
||||||
objectValue, fields, fieldType, variableValues);
|
objectValue, fields, fieldType, variableValues);
|
||||||
|
}
|
||||||
|
|
||||||
resultMap[responseKey] = responseValue;
|
resultMap[responseKey] = responseValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue