Marco Pierucci
10/17/2023, 2:10 PMConditionType
is an interface with the following implementations:
• ConditionExpression
• ComponentConditionBool
• ComponentConditionSelection
And because they might have different attributes here's how Im querying it:
visibilityCondition {
__typename
... on ComponentConditionBool {
component
fieldset
boolean
}
... on ComponentConditionSelection {
component
fieldset
selection
}
... on ConditionExpression {
operator
conditions {
__typename
... on ComponentConditionBool {
component
fieldset
boolean
}
... on ComponentConditionSelection {
component
fieldset
selection
}
}
}
}
[4:08 PM] SO far all god but the generated code I get is :
public data class VisibilityCondition(
public val __typename: String,
/**
* Synthetic field for inline fragment on ComponentConditionBool
*/
public val onComponentConditionBool: OnComponentConditionBool?,
/**
* Synthetic field for inline fragment on ComponentConditionSelection
*/
public val onComponentConditionSelection: OnComponentConditionSelection?,
/**
* Synthetic field for inline fragment on ConditionExpression
*/
public val onConditionExpression: OnConditionExpression?,
)
public data class OnComponentConditionBool(
public val component: ComponentType,
public val fieldset: TaskTemplateName,
public val boolean: Boolean,
)
public data class OnComponentConditionSelection(
public val component: ComponentType,
public val fieldset: TaskTemplateName,
public val selection: ComponentSelectionType,
)
public data class OnConditionExpression(
public val `operator`: LogicOperator,
public val conditions: List<Condition?>,
)
the generated code is not following the interfaces hireachy I'd hope ( I dont ahve a common interface to represent a VisibilityCondition
is there any way to achieve this or am i completely misunderstanding interfaces?Stylianos Gakis
10/17/2023, 2:25 PM... on ComponentConditionSelection {
component
fieldset
selection
}
into a proper gql fragment
fragment FooFragment on MyType
that you reuse, could that be what you are looking for here?
And depending on the codegenModels
option you’ve selected you might be getting a different result here in general, have you looked into that as well?Marco Pierucci
10/17/2023, 2:26 PMStylianos Gakis
10/17/2023, 2:29 PM… on Foo
vs doing
fragment MyFragment on Foo {}
And then in your query
{
...MyFragment
}
Like we do here, see difference between an inline fragment ... on TerminatedInFutureStatus
vs ... UpcomingAgreementChangeFragment
which is defined a bit lower in this file
In this case you’d get a super-type for that fragment which you can have common between places where you use it.
But I have a feeling I am misunderstanding what you may be going for here.Marco Pierucci
10/17/2023, 2:30 PMpublic data class BoolConditionFragment(
public val component: ComponentType,
public val fieldset: TaskTemplateName,
public val boolean: Boolean,
) : Fragment.Data
Stylianos Gakis
10/17/2023, 2:46 PMVisibilityCondition
that could be a fragment itself too. So in the ConditionExpression
case, you can ask for this fragment again. Is that what you are looking for?Marco Pierucci
10/17/2023, 2:48 PM