I updated from version 0.15.2 => 0.16.5 and fragments changed first char from uppercase to lowercase. Is that expected? I think type declarations look better when are uppercased.
Official typescript docs start uppercase (see "Type Aliases")
https://www.typescriptlang.org/docs/handbook/advanced-types.html
This actually used to be the default behavior but this got changed here: https://github.com/apollographql/apollo-codegen/issues/92
What are your thoughts on making this configurable? Maybe a -use-pascal-cased-type-names?
Any reason why they should not be pascal cased when generating typescript types?
@kroeder official TypeScript documentation has been updated (https://www.typescriptlang.org/docs/handbook/advanced-types.html)
Types (aliases or interfaces) start with a uppercase letter.
There's a styleguide for typescript (and I believe Flow too) that does state we should use PascalCase for names. The only weirdness here is that GraphQL operation/fragment names don't have that same rule.
The problem with PascalCasing is when dealing with acronyms. Forcing PascalCase on something like fragment CDMADetails { ... } results in type CdmaDetails = ... or interface CdmaDetails { ... }. whether or not that's intuitive is up for discussion.
Is there anything preventing folks from pascal casing their GraphQL fragment names?
@lewisf one workaround is too use Pascal name for query name (like in apollo official doc: https://www.apollographql.com/docs/react/basics/queries.html#basics)
Then apollo codegen will use the same Pascal name case for the types.
@wittydeveloper yeah agreed. Unfortunately, the GraphQL spec doesn't require pascal casing so we would have to decide whether or not we want to enforce that new constraint on the query names.
however -- pascal casing is also not a technical requirement by typescript or flow. it's just something that the communities have latched onto as good style.
So I don't know. Maybe the tool can output warnings instead?
Can we know why this was closed? We are interested in using pascal casing as well for our project.
A --use-pascal-casing option seems attractive.
Most helpful comment
Can we know why this was closed? We are interested in using pascal casing as well for our project.
A
--use-pascal-casingoption seems attractive.