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: set correct optionality when decoding list type #890

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Oct 4, 2024

Description of changes

Set correct optionality when decoding list types.

List types have four permutation when it comes to optionality.

  1. Required list, required element [String!]!
  2. Required list, nullable element [String]!
  3. Nullable list, required element [String!]
  4. Nullable list, nullable element [String]

The decoding is currently invalid for some of these cases.


The decoding should be:

  1. Required list, required element [String!]!
myCustomTypes = try values.decode([MyCustomType].self, forKey: .myCustomTypes)
  1. Required list, nullable element [String]!
myCustomTypes = try values.decode([MyCustomType?].self, forKey: .myCustomTypes)
  1. Nullable list, required element [String!]
myCustomTypes = try? values.decode([MyCustomType].self, forKey: .myCustomTypes)
  1. Nullable list, nullable element [String]
myCustomTypes = try? values.decode([MyCustomType?].self, forKey: .myCustomTypes)

Codegen Paramaters Changed or Added

N/A

Issue #, if available

#885

Description of how you validated changes

  • Unit tests

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • Breaking changes to existing customers are released behind a feature flag or major version update
  • Changes are tested using sample applications for all relevant platforms (iOS/android/flutter/Javascript) that use the feature added/modified
  • Changes are tested on windows. Some Node functions (such as path) behave differently on windows.
  • Changes adhere to the GraphQL Spec and supports the GraphQL types type, input, enum, interface, union and scalar types.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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.

1 participant