From 2b063f18a3f8538111faaa3eda4a84dae0ba2b87 Mon Sep 17 00:00:00 2001 From: Nicholas Bellucci Date: Tue, 1 Sep 2020 12:39:03 -0400 Subject: [PATCH 1/2] Added update to support collection of values conforming to argument value representable --- Sources/SociableWeaver/Protocols/Argument.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/SociableWeaver/Protocols/Argument.swift b/Sources/SociableWeaver/Protocols/Argument.swift index a1aaede..4a88b2a 100644 --- a/Sources/SociableWeaver/Protocols/Argument.swift +++ b/Sources/SociableWeaver/Protocols/Argument.swift @@ -84,6 +84,8 @@ extension Array: ArgumentValueRepresentable { return value.argumentValue } else if let value = value as? Dictionary { return value.argumentValue + } else if let value = value as? ArgumentValueRepresentable { + return value.argumentValue } return "" @@ -113,6 +115,8 @@ extension Dictionary: ArgumentValueRepresentable { return value.argumentValue } else if let value = value as? Dictionary { return value.argumentValue + } else if let value = value as? ArgumentValueRepresentable { + return value.argumentValue } else if let _ = value as? NSNull { return "null" } From b500575dbf368a9aeb6cdb07091c804d5d620b79 Mon Sep 17 00:00:00 2001 From: Nicholas Bellucci Date: Tue, 1 Sep 2020 12:44:11 -0400 Subject: [PATCH 2/2] Added test --- .../SociableWeaverGeneralTests.swift | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/SociableWeaverTests/SociableWeaverGeneralTests.swift b/Tests/SociableWeaverTests/SociableWeaverGeneralTests.swift index d974606..e2529d0 100644 --- a/Tests/SociableWeaverTests/SociableWeaverGeneralTests.swift +++ b/Tests/SociableWeaverTests/SociableWeaverGeneralTests.swift @@ -182,6 +182,30 @@ final class SociableWeaverGeneralTests: XCTestCase { XCTAssertEqual(String(describing: query), expected) } + func testOperationWithCustomEnumArray() { + enum PostCategories: EnumValueRepresentable { + case art + case music + case technology + } + + let query = Weave(.query) { + Object(Post.self) { + Field(Post.CodingKeys.title) + Field(Post.CodingKeys.content) + + Object(Post.CodingKeys.author) { + Field(Author.CodingKeys.id) + Field(Author.CodingKeys.name) + } + } + .argument(key: "category", value: [PostCategories.art, PostCategories.music, PostCategories.technology]) + } + + let expected = "query { post(category: [ART, MUSIC, TECHNOLOGY]) { title content author { id name } } }" + XCTAssertEqual(String(describing: query), expected) + } + static var allTests = [ ("testOperationWithArguments", testOperationWithArguments), ("testOperationWithFragment", testOperationWithFragment),