-
Notifications
You must be signed in to change notification settings - Fork 62
add a way to config GraphQL Codegen #175
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
Comments
Hi @yaquawa 👋, thanks for raising. I'm going to transfer to the Codegen repo to get some more eyes on it. |
@phani-srikar I use the generated types fo DTO objects, but the generated type mark the |
To hook into this discussion: the generated types are also all nullable for optional properties, which means that every single connection (for example) could be null, or an array of nulls (lol). This makes the generated types practically useless in a front-end, because you have to either start casting things to the "real" types or add all kinds of condition checks that never should exist anyway. To illustrate: a query for Assets: export type ListAssetsQuery = {
listAssets?: {
__typename: "ModelAssetsConnection",
items?: Array< {
__typename: "Asset",
id: string,
createdAt: string,
updatedAt: string,
} | null > | null,
nextToken?: string | null,
} | null,
}; Questions I have about this:
All of this leads to incredibly (and overly) difficult FE implementation and there's no way around it, except for manually creating types (which defeats the whole point of generating them). To further illustrate my point, here's a quick example of how improper these types are: https://www.typescriptlang.org/play?#code/C4TwDgpgBAYg9nKBeKBvAUFKAzBB+ALigEEAnUgQxAB4BnYUgSwDsBzAPgG50BfddUJCgAhCqWRpMUAEZjCJclToMWrKAB8ozAK4AbXew1a9u7n3QBjOM3o4AjEXiIUGLLjhEd+gDS9+Vm2AcACZHBAlXHAQiAG0AXV9zANtsAGYw50k3aKgYr10Ev0trFIAWDIipd1iAcncawqSSoOkHETFKrFlSTxNE-2aZUPbxFylu2MaBwJl0kc6ZMVj8qeKZ6XL5sa6l3JrdOF0GxKA Optional properties shouldn't be nullable, they're either there or not and it leads to a whole host of nested problems, including strange arrays of nulls being possible. |
@TheDutchCoder Thanks for putting this out. It looks like a bug for the type generation of graphql operations. I will look into this and make a fix soon |
Same issue here. In the example above the resulting type of |
Boop |
any updates on the issue? |
Is this related to a new or existing framework?
No response
Is this related to a new or existing API?
No response
Is this related to another service?
No response
Describe the feature you'd like to request
I want to remove
__typename
from theapi.ts
, with the raw GraphQL Codegen, I could config this by the skipTypename option, but how to config this in Amplify CLI ?Additional context
No response
Is this something that you'd be interested in working on?
The text was updated successfully, but these errors were encountered: