Problem
Currently can't compare two GraphQLResult even though the data is the same.
I'm currently using swift-testing with Swift 6.0.2
letqueryOrganizationBySlug:String=""" query FindSingleOrganization($slug: String!) { findSingleOrganization(slug: $slug) { slug displayName details domain } }"""letvariables:[String:Map]=["slug":"acme-corp"]letgraphQLRequest=GraphQLRequest(query: query, variables: variables)letencoder=GraphQLJSONEncoder()letbuffer=ByteBuffer(data:try encoder.encode(graphQLRequest))letresponse:GraphQLResult=tryawait client.runGraphQLQuery(
url:"/graphql",
buffer: buffer
)letexpected:GraphQLResult=GraphQLResult(
data:["findSingleOrganization":["slug":"acme-corp","displayName":"Acme Corporation","details":"A leading technology company","domain":"acme.com"]])
#expect(response == expected)However I'm getting an issue on comparison even though GraphQLResult is Equatable. The error is as follows:
✘ Expectation failed:(response →{"data":{"findSingleOrganization":{"displayName":"Acme Corporation","details":"A leading technology company","domain":"acme.com","slug":"acme-corp"}}})==(expected →{"data":{"findSingleOrganization":{"slug":"acme-corp","displayName":"Acme Corporation","details":"A leading technology company","domain":"acme.com"}}})Which we can see that the data is the same, the only thing is that the data is in differing orders:
[{"data":{"findSingleOrganization":{"details":"A leading technology company","domain":"acme.com","slug":"acme-corp","displayName":"Acme Corporation"}}},{"data":{"findSingleOrganization":{"slug":"acme-corp","displayName":"Acme Corporation","details":"A leading technology company","domain":"acme.com"}}}]What's the proper way to compare the results?
In addition, I used
letgraphQLRequest=GraphQLRequest(query: query, variables: variables)letencoder=GraphQLJSONEncoder()
Problem
Currently can't compare two
GraphQLResulteven though the data is the same.I'm currently using swift-testing with Swift 6.0.2
However I'm getting an issue on comparison even though
GraphQLResultisEquatable. The error is as follows:Which we can see that the data is the same, the only thing is that the data is in differing orders:
What's the proper way to compare the results?
In addition, I used