[TypeScript] Add __typename to typings
See original GitHub issueI use GraphQL interfaces.
When querying for a field that might be any type implementing a specific interface I need to know which implementation it is, for this I currently use __typename
.
Would be great if you would add the __typename
field for all typings (should probably be an optional field).
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
Documentation - Advanced Types - TypeScript
"typename" , where "typename" can be one of typeof operator's return ... Just like interfaces, type aliases can also be generic - we...
Read more >TypeScript with GraphQL done right - Charly Poly
TypeScript helps with typing data and following how the data is used and transformed by subsequent functions or method calls.
Read more >TypeScript with Apollo Client - Apollo GraphQL Docs
Typing Render Prop components. To type render prop components, you'll first define a GraphQL query using the generated gql function (from src/__generated__/ ...
Read more >How To Create Custom Types in TypeScript - DigitalOcean
Though the basic types in TypeScript will cover many use cases, creating your own custom ... Add a double colon and then add...
Read more >How to set a property type to textable representation of Type ...
You might feel that this is redundant, but remember that structural typing means it's not. The type name Bar is irrelevant, and interface ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is true, but because GraphQL Code Generator doesn’t include
__typename
on individual fields, TS only reports it being available at the top-level.Example –
Given something like this:
I get
__typename
on the root-level query:But not on the individual
source
field,TL;DR - We should get
__typename
on fields, too.You are right, @leebenson , I’m working on a fix. Thank you!