Currently when using apollo-codegen
to generate TypeScript types for query definitions (ts-modern
target),
the generated types are called as the query name. So if you have a GetUserQuery
your basetype is called GetUserQuery
.
But in fact the type does not desribe the actual query, but the outcome, the result of the query, so it would be better
if the type would have been named like UserQueryResult
.
There is an issue in apollo-codegen where this issue is discussed: apollographql/apollo-tooling#315
But as there is currently no progress I wrote a little codemod (using jscodeshift)
that renames the types after they have been generated. You can find the transform.js
script below.