Skip to content

Commit dfcef5d

Browse files
fix: Removes null serialization check.
This was preventing custom Scalars from representing items using Map.null. In the case where the value cannot be serialized, the serialize method itself should throw an error (not return null).
1 parent c7a26f7 commit dfcef5d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Sources/GraphQL/Execution/Execute.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,17 +1018,10 @@ func completeLeafValue(returnType: GraphQLLeafType, result: Any?) throws -> Map
10181018
guard let result = result else {
10191019
return .null
10201020
}
1021-
10221021
let serializedResult = try returnType.serialize(value: result)
1023-
1024-
if serializedResult == .null {
1025-
throw GraphQLError(
1026-
message:
1027-
"Expected a value of type \"\(returnType)\" but " +
1028-
"received: \(result)"
1029-
)
1030-
}
1031-
1022+
1023+
// Do not check for serialization to null here. Some scalars may model literals as `Map.null`.
1024+
10321025
return serializedResult
10331026
}
10341027

0 commit comments

Comments
 (0)