From a88555b755425af315e9c18d6f7a274328974512 Mon Sep 17 00:00:00 2001 From: Jay Herron Date: Mon, 10 Oct 2022 16:12:13 -0600 Subject: [PATCH] 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). --- Sources/GraphQL/Execution/Execute.swift | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Sources/GraphQL/Execution/Execute.swift b/Sources/GraphQL/Execution/Execute.swift index 4250429c..b6b416bd 100644 --- a/Sources/GraphQL/Execution/Execute.swift +++ b/Sources/GraphQL/Execution/Execute.swift @@ -1018,16 +1018,9 @@ func completeLeafValue(returnType: GraphQLLeafType, result: Any?) throws -> Map guard let result = result else { return .null } - let serializedResult = try returnType.serialize(value: result) - if serializedResult == .null { - throw GraphQLError( - message: - "Expected a value of type \"\(returnType)\" but " + - "received: \(result)" - ) - } + // Do not check for serialization to null here. Some scalars may model literals as `Map.null`. return serializedResult }