Open egoist opened 4 years ago
I like this idea. I’ve made something like that but for REST API. For REST API there’s no way to obtain API scheme so I failed to make it really convenient. https://github.com/uetchy/MuffledAPI
GraphQL would play nice with API client generator.
https://github.com/graphql-editor/graphql-zeus is exactly what I was talking about 😮
Here's a more low-level library, only for generating typescript typings: https://graphql-code-generator.com/docs/getting-started/
Turns out graphql-code-generator can also generate a full client, you just need to combine multiple plugins: https://github.com/graphile/starter/blob/master/%40app/graphql/codegen.yml
A list of solutions: https://twitter.com/HasuraHQ/status/1222197037459890176
The problem
When accessing a GraphQL API, you typically do this:
It's verbose, but if you also use TypeScript, a decent amount of manual type declarations are needed for type safety and that makes it even more verbose:
The solution
I wonder if it's possible/practical to generate a JS/TS/Go SDK with built-in types from a random GraphQL endpoint, given that you are able to access its schema file.
So instead of using DSL, you use an actual language instead:
And it's type-safe by default.