-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve typing customization #480
Comments
Thanks for volunteering for this @nick-keller! Here are some of my thoughts, please feel free to challenge & discuss:
Paths should be absolute starting from the pgTyped config directory. We can consider relative paths later if there is demand.
It would be great to have type mapping conform to the following snippet. I am split on the "parameter" and "return" key names, maybe "parameterType" and "returnType" would be better. {
"typesOverrides": {
"date": "dayjs#Dayjs"
"myEnum": {
"parameter": "./types/enums.ts#MyEnum",
"return": "string"
}
}
Overriding just the parameter or return type should leave the other one set to default value.
That would be useful, but I see it as independent to the type overrides since it affects the types of the whole return/parameter sets and not individual fields, so suggesting to discuss it as a separate feature. |
To sum it up we could have: For imports
For return vs parameter
|
All looks good. Alias imports are a bit too much in my opinion, so I suggest to not add them. |
Actually alisases are very useful to solve naming conflict. From my experience with GraphQLCodegen (from which this spec is inspired) it was very handy to get out of tricky situations. |
Would really love to use this feature, any idea when it might be published to |
The PR #494 was merged 2 days ago, it should be good |
Once again, amazing work on your part @adelsz!
Here are a few ideas for improving typing with pgtyped. I'm ready to do it but I wanted to have everyone's aproval on the idea before going further.
Complex mappers
Today it supports basic TS types:
It would be nice to be able to specify imported types in the fashion of what GraphQL codegen does.
❓ What should be the root of the relative paths?
❓ What should be the specs of the format?
Different mapping for parameters
It would be nice to type parameters and return values differently, even if they are of the same PG type.
For instance
Decimal
are returned asstring
by PG, so all select should be typed as such, but when inserting, updating, or using it in a where clause PG accept both a string or a number.❓ What should the config file look like exactly?
❓ What is the behavior expected if you only override one of the two?
Customize generated types
Today is generates
interface
andenum
, it would be nice to choose betweentype
interface
and evenclass
and betweenenum
and string union.types as well
❓ What should the config file look like exactly?
The text was updated successfully, but these errors were encountered: