Hallo,
given the following GraphQL schema:
union ShippingServices = UPSServices | DHLServices | DPDServices
type UPSServices {
cod: CODService
}
type DHLServices {
cod: CODService
}
type DPDServices {
cod: CODService
}
type CODService {
amount: Float
reasonForTransfer: String
}
type Shipping @entity {
...
state: ShippingState!
}
and a fragment on the Angular side:
fragment FullShipping on Shipping {
...
services {
... on UPSServices {
cod {
amount
reasonForTransfer
}
}
... on DHLServices {
cod {
amount
reasonForTransfer
}
}
... on DPDServices {
cod {
amount
reasonForTransfer
}
}
}
}
Produces the following piece of TypeScript code:
export namespace FullShipping {
export type Fragment = {
....
services: Services;
};
export type Shipper = ShippingContact.Fragment;
export type Recipient = ShippingContact.Fragment;
export type Packages = Package.Fragment;
export type Services =
| UpsServicesInlineFragment
| DhlServicesInlineFragment
| DpdServicesInlineFragment;
export type UpsServicesInlineFragment = {
__typename?: "UPSServices";
cod?: Cod | null;
};
export type Cod = {
__typename?: "CODService";
amount?: number | null;
reasonForTransfer?: string | null;
};
export type DhlServicesInlineFragment = {
__typename?: "DHLServices";
cod?: _Cod | null;
};
export type _Cod = {
__typename?: "CODService";
amount?: number | null;
reasonForTransfer?: string | null;
};
export type DpdServicesInlineFragment = {
__typename?: "DPDServices";
cod?: __Cod | null;
};
export type _Cod = {
__typename?: "CODService";
amount?: number | null;
reasonForTransfer?: string | null;
};
}
The type declaration "_Cod" is defined twice. The one at the bottom should be "__Cod" (two underscores).
@blissi which version of the codegen and the template do you use?
@kamilkisiela I'm not sure it that's a core bug or a template bug.. what do you think?
It is
"graphql-code-generator": "^0.12.2",
"graphql-codegen-apollo-angular-template": "^0.12.3",
@blissi Can you please try to update both to the latest?
@dotansimha thank you, that fixed it! I didn't check if there are newer versions, sorry for that.
Most helpful comment
@dotansimha thank you, that fixed it! I didn't check if there are newer versions, sorry for that.