apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.89k stars 730 forks source link

Implement Apollo Link #3452

Closed wow-such-amazing closed 1 month ago

wow-such-amazing commented 1 month ago

Use case

There are cases when you need to run Query A in order to have information to run Query B. Of course there are ways to solve this issue on the schema level, but it's not always possible.

Describe the solution you'd like

I've found this solution on the react framework which seems to be solving this exact issue. And I think it will be interesting to have it in the ios framework as well 👀

Though it's not an urgent one of course and in the meantime we can combine requests on our own in the code.

https://www.apollographql.com/docs/react/api/link/introduction

BobaFetters commented 1 month ago

@wow-such-amazing ApolloLink functions as a middleware in the networking layer to handle the steps of executing a single query. This wouldn’t inherently solve the problem of needing data from Query A to pass to Query B unless you are adding a link to your chain to do so, which is probably a bad design choice, since the chain is run on every query, not just Query A. This functions similarly to the existing interceptor chain setup in Apollo iOS which also acts as a middleware to handle steps of a single operation. Theoretically you could have an interceptor to handle what you are asking, but the right way to handle this would be to run Query A in your code and then take the result and run Query B.

We are currently working on a 2.0 version which will rework the networking layer of Apollo iOS, here is the RFC for that, however this also won’t solve the issue described.

github-actions[bot] commented 1 month ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.