Open svelue opened 1 year ago
Hi, @svelue do you know if there have been any updates on this one? I think I'm having the same problem with my application right now.
Hey, I don't know, I think we removed all fragments from our SS configurations and never tried again so far.
I have a similar problem. Here is what I found in the generated client. A full constructor call is generated for only one of the union types. For all other types, the constructor call is incomplete `private global::StrawberryShakeTests.State.ICatalogUnitedServicesData Deserialize_NonNullableICatalogUnitedServicesData(global::System.Text.Json.JsonElement? obj) { if (!obj.HasValue) { throw new global::System.ArgumentNullException(); }
var typename = obj.Value.GetProperty("__typename").GetString();
if (typename?.Equals("AdditionalCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.AdditionalCatalogServiceData(typename, id: Deserialize_NonNullableString(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "id")), serviceActiveDays: Deserialize_Int32(global::StrawberryShake.Json.JsonElementExtensions.GetPropertyOrNull(obj, "serviceActiveDays")));
}
if (typename?.Equals("LogoOnMainPageCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.LogoOnMainPageCatalogServiceData(typename);
}
if (typename?.Equals("CvDbCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.CvDbCatalogServiceData(typename);
}
if (typename?.Equals("HotCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.HotCatalogServiceData(typename);
}
if (typename?.Equals("LogoInPortalCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.LogoInPortalCatalogServiceData(typename);
}
if (typename?.Equals("LogoInRubricCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.LogoInRubricCatalogServiceData(typename);
}
if (typename?.Equals("VacancyPackageCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.VacancyPackageCatalogServiceData(typename);
}
if (typename?.Equals("VacancyPublicationCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.VacancyPublicationCatalogServiceData(typename);
}
if (typename?.Equals("MarketingCatalogService", global::System.StringComparison.Ordinal) ?? false)
{
return new global::StrawberryShakeTests.State.MarketingCatalogServiceData(typename);
}
throw new global::System.NotSupportedException();
}`
Query: `query GetFullOrder($id: ID!) { myOrder(id: $id) { id positions { count details { ...OrderPositionPublicationItem ...OrderPositionHotItem ...OrderPositionVacancyPackageItem ...OrderPositionCvdbItem ...OrderPositionAdditionalItem ...OrderPositionLogoOnMainItem ...OrderPositionLogoInPortalItem ...OrderPositionLogoInRubricItem ...OrderPositionMarketingItem typename } typename } typename } } fragment OrderPositionPublicationItem on OrderPositionVacancyPublicationServiceDetails { service { detailsUnion { ... on VacancyPublicationCatalogService { id serviceActiveDays typename } typename } typename } __typename }
fragment OrderPositionHotItem on OrderPositionHotServiceDetails { service { detailsUnion { ... on HotCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionVacancyPackageItem on OrderPositionVacancyPackageServiceDetails { service { detailsUnion { ... on VacancyPackageCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionCvdbItem on OrderPositionCvDbServiceDetails { service { detailsUnion { ...on CvDbCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionAdditionalItem on OrderPositionAdditionalServiceDetails { service { detailsUnion { ...on AdditionalCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionLogoOnMainItem on OrderPositionLogoOnMainServiceDetails { service { detailsUnion { ... on LogoOnMainPageCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionLogoInPortalItem on OrderPositionLogoInPortalServiceDetails { service { detailsUnion { ... on LogoInPortalCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionLogoInRubricItem on OrderPositionLogoInRubricServiceDetails { service { detailsUnion { ... on LogoInRubricCatalogService { id serviceActiveDays typename } typename } typename } typename }
fragment OrderPositionMarketingItem on OrderPositionMarketingServiceDetails { service { detailsUnion { ... on MarketingCatalogService { id serviceActiveDays typename } typename } typename } typename }`
I think I've just hit this as well
@michaelstaib Any updates on this one? Unfortunately this problem gets worse when using uniontypes in uniontypes. Since fragments are not working strawberryshake does not generate a common interface but a lot identical ones with _1, _2, ... suffix. This makes it quite hard and error prone to map the client results.
SS gets a new generator soon ... we are at the moment busy with the server and fusion, but will soon start iterating on Strawberry Shake again.
Is there an existing issue for this?
Product
Strawberry Shake
Describe the bug
When creating a client, based on a schema with union types the generated classes does not contain the requested fields when they are requested using fragments. Same clients are working as expected with SS12.x
Steps to reproduce
StrawberryShakeUnionTypeBug
The repo contains a simple client which shows the error.
Relevant log output
No response
Additional Context?
No response
Version
13.0.5