Apollo-android: Support for @client directive and local only fields

Created on 27 Sep 2020  路  3Comments  路  Source: apollographql/apollo-android

Is your feature request related to a problem? Please describe.
Need to add a custom variable in generated class that not in Query

Describe the solution you'd like
I need to add some custom variables in generated class that not present in Query file. That is , i need a boolean isExpanded variable in generated class for a query , that not included in query field.(for programming only usage)

Is that possible ?

Feature

Most helpful comment

@RageshAntony can you detail why wrapping the generated model to add your data is not a good solution in your case? I'm trying to see if @client directive and web-like local only fields could add value there. I'm not really sure how that would work with Kotlin but it might be something worth exploring.

Yeah I tried isExpanded @client in gql file in Android project and when building, apollo throwing error .

Ok I wrap inside an another class like you suggested . No problem

And one suggestion

These local fields (@ client) is an awesome feature . Please try to support them in Apollo-Android code generation

Thank You

All 3 comments

Hi 馃憢 , this is not possible. If you want to attach some data to a generated model, you can write a wrapper class that will add data.

@RageshAntony can you detail why wrapping the generated model to add your data is not a good solution in your case? I'm trying to see if @client directive and web-like local only fields could add value there. I'm not really sure how that would work with Kotlin but it might be something worth exploring.

@RageshAntony can you detail why wrapping the generated model to add your data is not a good solution in your case? I'm trying to see if @client directive and web-like local only fields could add value there. I'm not really sure how that would work with Kotlin but it might be something worth exploring.

Yeah I tried isExpanded @client in gql file in Android project and when building, apollo throwing error .

Ok I wrap inside an another class like you suggested . No problem

And one suggestion

These local fields (@ client) is an awesome feature . Please try to support them in Apollo-Android code generation

Thank You

Was this page helpful?
0 / 5 - 0 ratings