@@ -264,12 +264,7 @@ func executeFieldsSerially(
264264 path: fieldPath
265265 )
266266
267- guard let r = result else {
268- return results
269- }
270-
271- results [ field. key] = r
272-
267+ results [ field. key] = result
273268 return results
274269 }
275270}
@@ -285,29 +280,13 @@ func executeFields(
285280 path: [ IndexPathElement ] ,
286281 fields: [ String : [ Field ] ]
287282) throws -> Map {
288- let finalResults : [ String : Map ] = try fields. reduce ( [ : ] ) { results, field in
289- var results = results
290- let fieldASTs = field. value
291- let fieldPath = path + [ field. key] as [ IndexPathElement ]
292-
293- let result = try resolveField (
294- exeContext: exeContext,
295- parentType: parentType,
296- source: sourceValue,
297- fieldASTs: fieldASTs,
298- path: fieldPath
299- )
300-
301- guard let r = result else {
302- return results
303- }
304-
305- results [ field. key] = r
306-
307- return results
308- }
309-
310- return . dictionary( finalResults)
283+ return try executeFieldsSerially (
284+ exeContext: exeContext,
285+ parentType: parentType,
286+ sourceValue: sourceValue,
287+ path: path,
288+ fields: fields
289+ )
311290}
312291
313292/**
@@ -491,13 +470,15 @@ func resolveField(
491470 source: Map ,
492471 fieldASTs: [ Field ] ,
493472 path: [ IndexPathElement ]
494- ) throws -> Map ? {
473+ ) throws -> Map {
495474 let fieldAST = fieldASTs [ 0 ]
496475 let fieldName = fieldAST. name. value
497476
498- guard let fieldDef = getFieldDef ( schema: exeContext. schema, parentType: parentType, fieldName: fieldName) else {
499- return nil // TODO: this used to be "undefined"
500- }
477+ let fieldDef = getFieldDef (
478+ schema: exeContext. schema,
479+ parentType: parentType,
480+ fieldName: fieldName
481+ )
501482
502483 let returnType = fieldDef. type
503484 let resolve = fieldDef. resolve ?? defaultResolve
@@ -612,7 +593,7 @@ func completeValueCatchingError(
612593 // If `completeValueWithLocatedError` returned abruptly (threw an error),
613594 // log the error and return null.
614595 exeContext. errors. append ( error)
615- return . null // TODO: this was nil before
596+ return . null
616597 } catch {
617598 fatalError ( )
618599 }
@@ -948,19 +929,7 @@ func defaultResolveType(
948929 * of calling that func while passing along args and context.
949930 */
950931func defaultResolve( source: Map , args: [ String : Map ] , context: Map , info: GraphQLResolveInfo ) -> Map {
951- // ensure source is a value for which property access is acceptable.
952- if case . dictionary( let source) = source {
953- let property = source [ info. fieldName]
954-
955- // TODO: Dynamic Shit
956- // if (typeof property === 'func') {
957- // return source[info.fieldName](args, context)
958- // }
959-
960- return property!
961- }
962-
963- return . null
932+ return source [ info. fieldName]
964933}
965934
966935/**
@@ -976,7 +945,7 @@ func getFieldDef(
976945 schema: GraphQLSchema ,
977946 parentType: GraphQLObjectType ,
978947 fieldName: String
979- ) -> GraphQLFieldDefinition ? {
948+ ) -> GraphQLFieldDefinition {
980949 if fieldName == SchemaMetaFieldDef . name && schema. queryType. name == parentType. name {
981950 return SchemaMetaFieldDef
982951 } else if fieldName == TypeMetaFieldDef . name && schema. queryType. name == parentType. name {
@@ -985,5 +954,6 @@ func getFieldDef(
985954 return TypeNameMetaFieldDef
986955 }
987956
988- return parentType. fields [ fieldName]
957+ // we know this field exists because we passed validation before execution
958+ return parentType. fields [ fieldName] !
989959}
0 commit comments