comigor / artemis

Build dart types from GraphQL schemas and queries
MIT License
495 stars 119 forks source link

Generate queries in the background based on usage #111

Open LasseRosenow opened 4 years ago

LasseRosenow commented 4 years ago

For javascript there is a module called gqless: https://gqless.dev/

It basically generates all your queries etc. based on how you use them in your code. So you don't need any .query.graqhql files anymore and you also don't need to update them because you need a new property in your request somewhere within your app.

But you still get auto completion because gqless uses the schema.graphl file to generate the types for that.

So I think that this approach is pretty cool as you will automatically fetch the most minimal amount of data from your server as possible, because your code defines, what you need and you don't fetch to much just because you put to much fields into your local .query.graphql file.. Also the general usage is much faster as you don't need to write those files anymore at all.

So I think it would be amazing to have such a feature in Artemis. What do you think?

comigor commented 4 years ago

Wow, that seems amazing!

I have not used it, but it seems this integration is deeper and closer to Flutter than on Artemis itself (or any Dart-only package). I think there could be another package which does that, using Artemis to generate the needed typings.

The schema could be parsed and Artemis would be used to generate temporary typings of the whole schema and later have another generator to parse those usages and recreate the query to be sent to the server. Hence the integration with Flutter and its widgets.

That's somewhat similar to https://github.com/comigor/artemis/issues/104

Interesting project though, I'll take a curious look in the future but right now I'm pretty busy on work and personal stuff and couldn't even finish the RFC about types generation :(