3 ms·
The first thing that popped in my head was also how this compares to Apollo CLI's type generation (https://github.com/apollographql/apollo-tooling https://githu
by fro0116 8y ago
The first thing that popped in my head was also how this compares to Apollo CLI's type generation (https://github.com/apollographql/apollo-tooling https://github.com/apollographql/apollo-tooling, formerly apollo-codegen).
On a cursory glance, it seems like with this tool, you write a JS object in the same shape as the query, manually specifying the type of each field in that object, and then it generates the query for you to pass to graphql clients, as well as the types associated with the result of that query for you to use in your app. Whereas with Apollo's codegen, you write the query in graphql syntax, then run a CLI command to generate the types associated with that query for you to import and use.
It seems with this tool, you'd still have to manually state the type of each field (when that information can be perfectly inferred from the schema as demonstrated by Apollo's codegen), and you'd lose the ability to take advantage of tools that work with the graphql syntax to provide things like autocomplete based on your graphql schema while you're writing the query itself (https://github.com/apollographql/vscode-graphql https://github.com/apollographql/vscode-graphql, for instance). Unfortunately I'm not yet able see any benefits you'd get over Apollo's codegen in return. Happy to be enlightened if I'm missing anything.
- lars_francke 8y agoThat's my understanding as well. This would help for tools other than Apollo which do not have the codegen capability but as it is I'm not sure what the benefit is for Apollo users.
- fro0116 8y agoApollo CLI isn't even coupled to Apollo Client though. You can use it to generate types for any graphql query as long as you can also provide a schema for it to infer types from.
- acro5piano 8y agoThank you for pointing out. I haven't used such tools, but with editor support we can do furthermore. Type information can be perfectly inferred from the schema. I agree though.