From ec8832de1f790b1c49f8258a51f4e2fa8312a6dd Mon Sep 17 00:00:00 2001 From: Arnaud Dorgans Date: Wed, 8 Nov 2023 20:04:07 +0100 Subject: [PATCH] fix Array JSONEncodable --- apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift | 2 +- .../ApolloAPI/JSONStandardTypeConversions.swift | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift b/apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift index afbd73399..e8018ec00 100644 --- a/apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift +++ b/apollo-ios/Sources/ApolloAPI/GraphQLOperation.swift @@ -116,7 +116,7 @@ public protocol GraphQLOperationVariableValue { } extension Array: GraphQLOperationVariableValue -where Element: GraphQLOperationVariableValue & Hashable {} +where Element: GraphQLOperationVariableValue & JSONEncodable & Hashable {} extension Dictionary: GraphQLOperationVariableValue where Key == String, Value == GraphQLOperationVariableValue { diff --git a/apollo-ios/Sources/ApolloAPI/JSONStandardTypeConversions.swift b/apollo-ios/Sources/ApolloAPI/JSONStandardTypeConversions.swift index 6805b4ca3..39079643e 100644 --- a/apollo-ios/Sources/ApolloAPI/JSONStandardTypeConversions.swift +++ b/apollo-ios/Sources/ApolloAPI/JSONStandardTypeConversions.swift @@ -147,14 +147,8 @@ extension JSONObject: JSONDecodable { } } -extension Array: JSONEncodable { +extension Array: JSONEncodable where Element: JSONEncodable { @inlinable public var _jsonValue: JSONValue { - return map { element -> JSONValue in - if case let element as JSONEncodable = element { - return element._jsonValue - } else { - fatalError("Array is only JSONEncodable if Element is") - } - } + map(\._jsonValue) } }