Hi,
We have several components that feature the same enumeration. That is, each component (ComponentTilesTypeA, ComponentTilesTypeB) features an enumeration field (order
) with the same name and the exact same answering options.
These components can be placed within a dynamic zone, which we query with a GraphQL query like this:
fragment TileContent on ProductTilesDynamicZone {
__typename
... on ComponentTilesTypeA {
id
foo0
order
}
... on ComponentTilesTypeB {
id
foo1
bar2
order
}
}
where order
is the enumeration field. Because Strapi assigns each enum a different type, this query leads to a validation error with GraphQL:
{
"error": {
"errors": [
{
"message": "Fields \"order\" conflict because they return conflicting types \"ENUM_COMPONENTTILESTYPEA_ORDER!\" and \"ENUM_COMPONENTTILESTYPEB_ORDER!\". Use different aliases on the fields to fetch both if this was intentional.",
Is there any way to force Strapi to use the same type for these enums programmatically? I looked into the GraphQL API documentation but I didn’t find anything on modifying types.
Or can anyone think of other potential solutions?
Options considered but not deemed good enough:
- Using different aliases in the query for
order
in every component type. This adds significant complexity to the client. - Creating a component X that contains only the enumeration field. Then add a field for component X to the components of the dynamic zone. This significantly complicates the user interface and structure of the response.
Options tried leading to an error:
- Setting the same “Name override for GraphQL” for all enum fields. Leads to a fatal error when the server starts.
Thanks
System Information
- Strapi Version:
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version: