This repository was archived by the owner on Oct 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 129
Add "freezed" feature to codegen #370
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Before reporting a bug, please test the beta branch!
Bug description
For now it's pretty hard to use generated classes from "union" type;
For example now, to identify object and use it's field i need to use this construction:
query xxx {
sometype: {
...on X {
onlyXField
}
...on Y {
onlyYField
}
...on Z {
onlyZField
}
}
}
if (parsedObject is X) {
return x.onlyXField;
}
if (parsedObject is Y) {
return y.onlyYField;
}
if (parsedObject is Z) {
return z.onlyZField;
}
// unsupported type
return error;
and if i use mixin (fragments inside queries), then i'd have to:
if (parsedObject is X) {
return (x as XMixin).onlyXField;
}
if (parsedObject is Y) {
return (y as XMixin).onlyYField;
}
if (parsedObject is Z) {
return (z as XMixin).onlyZField;
}
// unsupported type
return error;
with "freezed" it would be something like this:
x.map(
X: (it) => it.onlyXField,
Y: (it) => it.onlyYField,
Z: (it) => it.onlyZField,
)
henriqueArrazao, ekremkenter, mdrideout and AristideVBopsb
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request