You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gql): add discriminated union type support - ProductOrSubscription (#33)
Add ProductOrSubscription union type to GraphQL schema and implement
discriminated union type narrowing across all platforms (TypeScript,
Swift, Kotlin, Dart).
Changes:
- Add `union ProductOrSubscription = Product | ProductSubscription` to
GraphQL schema
- Update type generators to handle union of unions pattern
- Optimize platform-specific type extraction with nested pattern
matching
- Fix TypeScript FetchProductsResult to support mixed arrays
- Add ProductOrSubscription interface implementation to Product and
ProductSubscription
TypeScript:
- Extend FetchProductsResult type to include `(Product |
ProductSubscription)[]`
- Fix Query.fetchProducts to use FetchProductsResult type alias
Swift:
- Use nested pattern matching for direct type extraction
- Change `.productSubscription(let sub), case
.productSubscriptionIos(let val)` to
`.productSubscription(.productSubscriptionIos(let val))`
Kotlin:
- Add ProductOrSubscription interface implementation with override
modifiers
- Optimize type extraction to filter platform-specific types directly
- Change from wrapper types to direct sealed interface casting
Dart:
- Add implements clause for Product and ProductSubscription
- Handle union of unions in type generation
Generator scripts:
- Add getInterfaces() type check for union members in all generators
- Remove manual ProductOrSubscription post-processing (now
auto-generated)
- Add post-processing to make unions implement ProductOrSubscription
Benefits:
- Enables type-safe discriminated union narrowing
- Eliminates unnecessary intermediate object creation
- Platform-specific code only handles its own types
- Better IDE autocomplete and compile-time type safety
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Fetch mixed collections of products and subscriptions in a single
"all" response.
* Introduced a unified ProductOrSubscription type to handle products and
subscriptions consistently across platforms.
* **Chores**
* Updated GraphQL generation and language-specific type generators to
emit wrapper-based union handling.
* Updated GraphQL generator version metadata.
* **Refactor**
* Simplified platform-specific extraction and matching logic for
product/subscription items.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments