You can do this with GraphQL too:
https://github.com/graphql-editor/graphql-zeus
I did a 5 min talk about these newer breeds of codegen tools (where it's a single client SDK that does automatic return type inference based on the input args), they're really neat:
https://www.youtube.com/watch?v=7n3MeMFHiMk
(Skip to 2:14 to see the autocomplete/type-safety)