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
Suffix of generated types should maybe be "Result" instead of "Query" #315
Comments
Yeah, that's fair. On iOS, we generate actual query classes as We probably want to think about this in the context of #308, which is about generating query classes for TypeScript or Flow as well. |
It should probably be
|
...It would be great to come up with a convention and settle on naming scheme. For example, |
I think either a suffix of |
I also think |
Any chance this will be implemented? If your interested, I could try to help implementing... |
ICYI: I've written a little codemod script that renames the generated types after they have been generated by apollo-codegen (as workaround until this problem gets solved in apollo-codegen) You can find the transform script here: https://gist.github.com/nilshartmann/39e6dc755c91a60c1dc1911180e154b5 |
As @alamothe mentioned, suffixes disappeared with 0.20 version, which is breaking change and was not mentioned/explained in CHANGELOG.. so I am confused about the intentions behind it. I personally liked the suffixes.. so would at least appreciate explanation for this change. |
import { myQuery } from "./my-query.gql";
import { myQuery } from "./__generated__/myQuery"; Names conflict |
@jbaxleyiii since this issue have been closed, is there any official resolution to this problem? The generated name conflicts with my query |
Any resolution to this? |
@lewisf you contributed #304 a while ago, which I believe was when the suffix AFAIK it is possible to have a GraphQL schema that include a query and a mutation with the same name. In this case codegen would probably generate invalid code with duplicated identifiers. |
Is there any news on this? A suffix option would be great |
Today the types that are generated are named
GetFooQuery
. Becuase of this naming convention, it is quite easy for someone to assume that that type represents the actual query. But in reality it represents the result/reponse that the query will generate. If the types instead were namedGetFooResult
or something similar it might be easier to understand what the type represents. Or perhaps make it possible for the user to decide the suffix (perhaps it already is but I have not found that option).The generation examples now state:
Which is good becuase the file name
operation-result-types.ts
communicates what the generated types represents. If the type names did the same I think it would clear up some confusion.The text was updated successfully, but these errors were encountered: