gql
gql copied to clipboard
reuse fragments by their selection set
This is just an idea for an alternative implementation to #417
- Revert "[gql_code_builder] add dataClassConfig option to reuse class definitions for field selections that include only a single inline fragment spread"
- simpler version of reuse fragments with less scope
This is a different approach to reusing fragments and reduce duplication in the code.
The idea is: Keep a Map of (TypeName ,BuiltSet<SelectionNode>) -> Reference
for already generated fragments.
This will use the actual selections for figuring out whether a new class needs to be created or a fragment can be reused.
TODO: try if reusing generated subclasses for inline fragment spreads can also be optimized, without potential conflicts in types
TODO: potentially this can be extended to not only reuse fragments but all generated classes, if they have the same selections.
Drawbacks: the names of the generated classes are less stable and could change by adding new fragments which can be used
Advantage: IMO simpler to understand, easier to extend
Hey again @knaeckeKami :D I've tested it and for now, I am getting Out of memory error. I guess its because scope is much smaller than the previous solution and that's why.
And btw I had to manually modify fery_generator bcs the current version 0.8.2. expects dataClassConfig