Suggestion: Use Pick<T, K> to generate query types
See original GitHub issueIs your feature request related to a problem? Please describe. Currently, we just have a copy of original type for a query
Describe the solution you’d like I think a more clear approach would be to use Pick<T, K> operator to make a connection to the original type.
So this would be like this
export interface TypeA {
id: string;
name: string;
age: number;
}
export namespace MyQuery {
export type TypeA = Pick<TypeA, 'id' | 'name'>
}
See it’s in action here https://medium.com/@curtistatewilkinson/typescript-2-1-and-the-power-of-pick-ff433f1e6fb
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:25 (11 by maintainers)
Top Results From Across the Web
GraphQL schema basics
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >Generating Query Suggestions to Support Task-Based Search
ABSTRACT. We address the problem of generating query suggestions to support users in completing their underlying tasks (which motivated them.
Read more >Query Suggestions in InstantSearch.js - Algolia
Query Suggestions is a search experience that displays a list of possible queries that your users can select from as they type.
Read more >Unable to find any GraphQL type definitions for the following ...
I suggest thay you create a new file with a simple query, ... queries and mutations and use the codegen to generate the...
Read more >SQL IntelliSense and Autocomplete in SSMS | Redgate
You can also use it in a way that it both makes code suggestions ... To get the same information for a procedure,...
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
Plugin
typescript-client
I’ve been taking a look to this feature proposal, the idea of using Pick it’s quite interesting as y’all have mentioned before. I’d love to discuss what would be the best way implement this, as I have no much idea about the library, I’d really appreciate your opinion & hopefully guidance. I’ve noticed that the
typescript-client
is the responsible for generating the types that’d change, refactoring its handlebar template it’d probably work but yep, surely I’m missing a lot of corner cases.Check this example out and let’s discuss how we could solve it, the proposal is tested & working with
typescript-react-apollo
with no changes in its template.Query
Current Types
Proposal Iterate over the fields until all of them are primitive types (didn’t code it yet but I guess this is possible), it’d require to include the
typescript-server
in order to generate & pick the interfaces! Probably thePick
types have to includeMaybe
types too.cc/ @dotansimha @ardatan
Help wanted hahah 🙏🏻
Will do