Programmatically edit Query created by codegen

Hi,
We have static queries for the most part. But in a couple instances, some variables in the query are controlled by experiments. We are using @skip / @include directives to make this work for now. But we are also trying to explore if there is any other way to do this on the clients instead of letting the server validate it.
I was thinking that maybe there is a way to modify the query that is generated by Apollo (we are using the codegen scripts from the Xcode build phase), I could add/remove fragments from the query programmatically based on the experiment. Is that even possible?

Thanks in advance.

Hi @a123321 :wave:

What you’re wanting to do is unfortunately not possible. Apollo iOS is built around statically generated models which correspond to the queries at the time of generation. Supporting this kind of dynamic query behaviour is something we’re beginning to look into but it’s not planned on any roadmap and is likely some time away from being a reality.

Have you considered that there might be benefit in keeping the query logic on the server to capture analytics about the clients’ query path based on their experiment participation. Having the client adjust its query based on experiment could hide some valuable data; unless you’re capturing client-side analytics another way.

Thanks @calvincestari .
I was just exploring options. In case mobile features goes out before the server side does, I was looking at some way of adding/removing vars from client code.
In Android, I was told, they are able to parse the query and transform it by adding/deleting nodes. So, I thought we could do the same on iOS too but I was missing the documentations.