Graphql-code-generator: What solutions do we have for better names?

Created on 4 Mar 2019  路  3Comments  路  Source: dotansimha/graphql-code-generator

When generating types for the server-side the names are not too much of an issue but for the client side they become a little bit too ugly to look at.
E.g. "NewsfeedNewsfeed", "NewsfeedCommentNewsInlineFragment", "AnsweredQuestionAnsweredQuestion", "NotificationFieldsNewCommentInlineFragment", "UserUser"etc.

Logically it all makes sense generating such names but in terms of readibility I'm afraid it doesn't. The solution that comes to mind is to simply write all the ts types manually but this opens too many places for mistakes. Any ideas?

P.s. great work

enhancement plugins waiting-for-release

Most helpful comment

Hi @zenVentzi !
We are currently working on rewriting the TypeScript plugins (https://github.com/dotansimha/graphql-code-generator/pull/1353). We removed namespaces completly, and now we are using Pick<> to generate the result of queries. It means that each query will have only a single TypeScript type, and there will be no duplications/mis-matches/ugly names - only the name of the operation.

@SekibOmazic

All 3 comments

I have the same questions. I've tried with namespaces but then had real difficulties using them in my CRA application (CRA shows me namespaces are not supported)
For the time being I gave up and live with "ugly" names like AnsweredQuestionAnsweredQuestion

Hi @zenVentzi !
We are currently working on rewriting the TypeScript plugins (https://github.com/dotansimha/graphql-code-generator/pull/1353). We removed namespaces completly, and now we are using Pick<> to generate the result of queries. It means that each query will have only a single TypeScript type, and there will be no duplications/mis-matches/ugly names - only the name of the operation.

@SekibOmazic

Fix available in 1.0.0 馃憤

Was this page helpful?
0 / 5 - 0 ratings