Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Test Mock Custom Scalar conversion #2584

Merged
merged 3 commits into from
Oct 14, 2022
Merged

Conversation

AnthonyMDev
Copy link
Contributor

JSON Encoding the Mocks into the SelectionSet.DataDict was causing CustomScalar values to get encoded into their JSON values.

This implements a custom conversion of the Mock data into the correct format for the SelectionSet.DataDict.

Because of this, test mocks should have a dictionary of [String: AnyHashable] instead of JSONEncodableDictionary. We are not actually encoding these into JSON to convert to the SelectionSet.DataDict anymore.

To make that work with AnyHashable and the fields for lists of interfaces, we needed a coercive conversion function that forces the conversion of Array<any AnyMock> to Array<AnyHashable>.

Fixes #2582

@netlify
Copy link

netlify bot commented Oct 13, 2022

Deploy Preview for apollo-ios-docs canceled.

Name Link
🔨 Latest commit 1f5eff6
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docs/deploys/634891594e73a600083dcb07

@AnthonyMDev AnthonyMDev merged commit 6514da3 into main Oct 14, 2022
@AnthonyMDev AnthonyMDev deleted the test-mock-enum-crash branch October 14, 2022 17:39
@calvincestari calvincestari mentioned this pull request Oct 21, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using the test mock, touching a GraphQLEnum property will cause a crash
2 participants