diff --git a/graphql_parser/lib/src/language/lexer.dart b/graphql_parser/lib/src/language/lexer.dart index 1aed8b33..adb925ed 100644 --- a/graphql_parser/lib/src/language/lexer.dart +++ b/graphql_parser/lib/src/language/lexer.dart @@ -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 scan(String text, {sourceUrl}) { while (!scanner.isDone) { List 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)) { diff --git a/graphql_server/lib/graphql_server.dart b/graphql_server/lib/graphql_server.dart index eda1832f..f19b43cc 100644 --- a/graphql_server/lib/graphql_server.dart +++ b/graphql_server/lib/graphql_server.dart @@ -215,12 +215,19 @@ class GraphQL { for (var field in fields) { var fieldName = field.field.fieldName.name; - var fieldType = objectType.fields - .firstWhere((f) => f.name == fieldName, orElse: () => null) - ?.type; - if (fieldType == null) continue; - var responseValue = await executeField(document, fieldName, objectType, - objectValue, fields, fieldType, variableValues); + 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; + responseValue = await executeField(document, fieldName, objectType, + objectValue, fields, fieldType, variableValues); + } + resultMap[responseKey] = responseValue; } }