From 1ba9098262c593ee1c346019bb084a4bf7d3a867 Mon Sep 17 00:00:00 2001 From: Dieter Eberle Date: Wed, 1 Jul 2020 10:33:00 +0200 Subject: [PATCH] Fix cache key generation for arrays by calling orderIndependentKey for each element --- Sources/Apollo/GraphQLSelectionSet.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/Apollo/GraphQLSelectionSet.swift b/Sources/Apollo/GraphQLSelectionSet.swift index 9521d736dc..04e7bf55e6 100644 --- a/Sources/Apollo/GraphQLSelectionSet.swift +++ b/Sources/Apollo/GraphQLSelectionSet.swift @@ -89,6 +89,8 @@ private func orderIndependentKey(for object: JSONObject) -> String { return object.sorted { $0.key < $1.key }.map { if let object = $0.value as? JSONObject { return "[\($0.key):\(orderIndependentKey(for: object))]" + } else if let array = $0.value as? [JSONObject] { + return "\($0.key):[\(array.map { orderIndependentKey(for: $0) }.joined(separator: ","))]" } else { return "\($0.key):\($0.value)" }