Typescript noNamespace scalar issues
When using the noNamespace option in the typescript template. Types that have custom scalars, such as JSON, DateTime, ... are also prefixed with the query name. However this breaks the types as the scalars are only globally defined.
export type GetItemHistoryHistory = {
__typename?: "ItemHistory";
timestamp: GetItemHistoryDateTime;
reader?: GetItemHistoryReader | null;
location?: GetItemHistoryLocation | null;
};
should be (DateTime)
export type GetItemHistoryHistory = {
__typename?: "ItemHistory";
timestamp: DateTime;
reader?: GetItemHistoryReader | null;
location?: GetItemHistoryLocation | null;
};
I got you covered Mr @JannesV ! #471 - reproduced and fix in progress
I published a canary version: 0.11.0-alpha.4c054a57
@JannesV Could you check if it works for you?
Successfully published:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- graphql-codegen-typescript-mongodb-template@0.11.0-alpha.4c054a57
- graphql-codegen-typescript-react-apollo-template@0.11.0-alpha.4c054a57
- [email protected]
Great job dude! The scalars are now fixed. However it still "breaks" on enums. I should've clarified in my first post but I overlooked it and thought it only broke on custom scalars.
export type GetItemDetails_Properties = {
__typename?:
| GetItemDetailsTextPropertyTypeInlineFragment["__typename"]
| GetItemDetailsCheckboxPropertyTypeInlineFragment["__typename"]
| GetItemDetailsNumberPropertyTypeInlineFragment["__typename"]
| GetItemDetailsColorPropertyTypeInlineFragment["__typename"]
| GetItemDetailsDropdownPropertyTypeInlineFragment["__typename"]
| GetItemDetailsDropdownPropertyTypeOptionInlineFragment["__typename"]
| GetItemDetailsDatePropertyTypeInlineFragment["__typename"]
| GetItemDetailsTimePropertyTypeInlineFragment["__typename"]
| GetItemDetailsDateTimePropertyTypeInlineFragment["__typename"]
| GetItemDetailsFilePropertyTypeInlineFragment["__typename"];
name: string;
inputType: GetItemDetailsItemPropertyInputType;
} & (
| GetItemDetailsTextPropertyTypeInlineFragment
| GetItemDetailsCheckboxPropertyTypeInlineFragment
| GetItemDetailsNumberPropertyTypeInlineFragment
| GetItemDetailsColorPropertyTypeInlineFragment
| GetItemDetailsDropdownPropertyTypeInlineFragment
| GetItemDetailsDropdownPropertyTypeOptionInlineFragment
| GetItemDetailsDatePropertyTypeInlineFragment
| GetItemDetailsTimePropertyTypeInlineFragment
| GetItemDetailsDateTimePropertyTypeInlineFragment
| GetItemDetailsFilePropertyTypeInlineFragment);
How it should be (ItemPropertyInputType)
export type GetItemDetails_Properties = {
__typename?:
| GetItemDetailsTextPropertyTypeInlineFragment["__typename"]
| GetItemDetailsCheckboxPropertyTypeInlineFragment["__typename"]
| GetItemDetailsNumberPropertyTypeInlineFragment["__typename"]
| GetItemDetailsColorPropertyTypeInlineFragment["__typename"]
| GetItemDetailsDropdownPropertyTypeInlineFragment["__typename"]
| GetItemDetailsDropdownPropertyTypeOptionInlineFragment["__typename"]
| GetItemDetailsDatePropertyTypeInlineFragment["__typename"]
| GetItemDetailsTimePropertyTypeInlineFragment["__typename"]
| GetItemDetailsDateTimePropertyTypeInlineFragment["__typename"]
| GetItemDetailsFilePropertyTypeInlineFragment["__typename"];
name: string;
inputType: ItemPropertyInputType;
} & (
| GetItemDetailsTextPropertyTypeInlineFragment
| GetItemDetailsCheckboxPropertyTypeInlineFragment
| GetItemDetailsNumberPropertyTypeInlineFragment
| GetItemDetailsColorPropertyTypeInlineFragment
| GetItemDetailsDropdownPropertyTypeInlineFragment
| GetItemDetailsDropdownPropertyTypeOptionInlineFragment
| GetItemDetailsDatePropertyTypeInlineFragment
| GetItemDetailsTimePropertyTypeInlineFragment
| GetItemDetailsDateTimePropertyTypeInlineFragment
| GetItemDetailsFilePropertyTypeInlineFragment);
Thanks for the very quick assistance!
I'll take a look at it in few hours! That's good it works for scalars :D
@JannesV
I included scalars, enums and unions 0.11.0-alpha.c2ace11c
Could you try it out?
@kamilkisiela Works like a charm, great work man.