Graphql-code-generator: Add support for useLazyQuery

Created on 7 Aug 2019  路  7Comments  路  Source: dotansimha/graphql-code-generator

@apollo/react-hooks added useLazyQuery
https://www.apollographql.com/docs/react/api/react-hooks/#uselazyquery

It's possible to support it?

Adding a configuration like:
withLazyQuery: true

And generating a useQueryLazyComponent for each query, i wonder if it's the best way to do it.

enhancement plugins waiting-for-release

Most helpful comment

You can try it in the following canary version;

 1.5.1-alpha-e4e10196.6+e4e10196

All 7 comments

Maybe it would be a better solution to allow controlling what kind of code you want to generate for which query/mutation? E.g. by using directives on the operation definition?

I may not want to generate a lazy query component for each query in my project? Or is this something that should be handled by the bundler aka tree shaking?

A similar scenario already happens if you use hooks and hoc/component, in the end it/should be handled by the bundler.

That would be nice! I'll add this soon.

You can try it in the following canary version;

 1.5.1-alpha-e4e10196.6+e4e10196

Wow, that was fast. Seems to be working fine for me!
Thank you @ardatan

Added in 1.6.0.

It would be great if useLazyQuery could also be added to the Vue plugin #5258

Was this page helpful?
0 / 5 - 0 ratings