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
Fragments in Houdini are very component orientated and try to separate the concerns of pages and components and the fields they query. This is nice and seems to work great.
But, sometimes you just want to use a fragment to save having to repeat yourself dozens of times when writing a query. We have fields that can be translated for example, and for each field (e.g. privacy policy, legal notice etc) we query it for lots of languages. So the query would look something like this:
Unmasking the fragment using the @mask_disable directive allows us to access the fields at least but if you are using the queried fields as part of a form with a zod schema for example, or anything else with strict types, you still have the add " $fragments" keys in the generated types.
This causes lots of type errors and we are currently solving them by using a type helper to recursively omit the `" $fragements" from the types. Something like this:
typeOmitDistributive<T,KextendsPropertyKey>=Textendsany ? (Textendsobject ? Id<OmitRecursively<T,K>> : T) : never;typeId<T>={}&{[PinkeyofT]: T[P]};// Cosmetic use only makes the tooltips expad the type can be removed typeOmitRecursively<Textendsany,KextendsPropertyKey>=Omit<{[PinkeyofT]: OmitDistributive<T[P],K>},K>;typeOmitFragments<Textendsany>=OmitRecursively<T,' $fragments'>;constform=awaitsuperValidate(tenantasOmitFragments<typeoftenant>,legalTextsSchema);
It would be nice to have an option to disable both the masking and the adding of the $fragment types so that one can just as a fragment as is, plain and simple, without anything added on top.
Criticality
cool improvement, my projects will benefit from it
The text was updated successfully, but these errors were encountered:
I understand this is a slightly confusing behavior but in our experience, duplicated fields across queries are more of a coincidence than a design constraint. Because of this, we have built fragments in houdini to push users to avoiding coupling between disconnected parts of an application. As such, we don't have any plans to change the fragment behavior to avoid masking by default.
Describe the feature
Fragments in Houdini are very component orientated and try to separate the concerns of pages and components and the fields they query. This is nice and seems to work great.
But, sometimes you just want to use a fragment to save having to repeat yourself dozens of times when writing a query. We have fields that can be translated for example, and for each field (e.g. privacy policy, legal notice etc) we query it for lots of languages. So the query would look something like this:
And using a fragment something like this:
Unmasking the fragment using the
@mask_disable
directive allows us to access the fields at least but if you are using the queried fields as part of a form with a zod schema for example, or anything else with strict types, you still have the add" $fragments"
keys in the generated types.This causes lots of type errors and we are currently solving them by using a type helper to recursively omit the `" $fragements" from the types. Something like this:
It would be nice to have an option to disable both the masking and the adding of the $fragment types so that one can just as a fragment as is, plain and simple, without anything added on top.
Criticality
cool improvement, my projects will benefit from it
The text was updated successfully, but these errors were encountered: