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" } 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),