├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 typescript-cheatsheets 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # graphql-typescript-cheatsheet 2 | 3 | Resources for End-to-End typing with GraphQL and TypeScript 4 | 5 | ## Notes 6 | 7 | There is something informally called the "keying-in" operator that is very handy for accessing generated TypeScript types from your GraphQL schema. 8 | 9 | ```ts 10 | // generated typescript response from schema 11 | type APIResponse = { 12 | user: { 13 | userId: string 14 | friendList: { 15 | count: number 16 | } 17 | } 18 | } 19 | you need to the type of APIResponse.user.friendList but don't know it upfront 20 | type FriendList = APIResponse['user']['friendList'] 21 | ``` 22 | 23 | It looks kinda obvious but can be really handy. 24 | 25 | ## Libraries 26 | 27 | - typegraphql: https://github.com/19majkel94/type-graphql/ Create GraphQL schema and resolvers with TypeScript, using classes and decorators! [now at 1.0](https://dev.to/michallytek/announcing-typegraphql-1-0-1d7h) 28 | - `graphql-code-generator`: https://github.com/dotansimha/graphql-code-generator ([Usage example](https://formidable.com/blog/2019/strong-typing/)) 29 | - graphql nexus 30 | - smalller libs 31 | - https://github.com/capaj/decapi 32 | - https://github.com/prismake/typegql 33 | 34 | ## Podcasts 35 | 36 | - Natalie Qabazard on the [Real Talk JS Podcast on GraphQL + Typescript](https://realtalkjavascript.simplecast.fm/42ba5d10) adoption at Zillow 37 | --------------------------------------------------------------------------------