apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.85k stars 707 forks source link

Passing GraphQLEnum to mocks fails #2970

Open alexjameslittle opened 1 year ago

alexjameslittle commented 1 year ago

Summary

When you pass enum to create test mocks, you get a JSON decoding error:

couldNotConvert(value: AnyHashable(ApolloAPI.GraphQLEnum<ProfileFriendStatus>.case(ProfileFriendStatus.none)), to: Swift.String)

Version

1.1.2

Steps to reproduce the behavior

You need a type that has an enum for a field.

enum ProfileFriendStatus {
  NONE
  FRIENDS
  PENDING
} 

type Profile {
  friendStatus: ProfileFriendStatus!
}

Then when trying to create the mock like so, it always fails

let mock = Mock<Profile>(friendStatus: GraphQLEnum<ProfileFriendStatus>.case(.none))

Logs

No response

Anything else?

No response

calvincestari commented 1 year ago

Possibly related to https://github.com/apollographql/apollo-ios/issues/2830 and https://github.com/apollographql/apollo-ios/issues/2686.