Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ApolloClient with swift-corelibs-foundation 5.10.1 #3410

Open
BadPirate opened this issue Jul 11, 2024 · 5 comments
Open

Use ApolloClient with swift-corelibs-foundation 5.10.1 #3410

BadPirate opened this issue Jul 11, 2024 · 5 comments
Labels
feature New addition or enhancement to existing solutions Linux Issues specific to use (or at least attempted use) on Linux

Comments

@BadPirate
Copy link

BadPirate commented Jul 11, 2024

Use case

Currently swift-corelibs-foundation (used for server iOS apps like Vapor) is using FoundationNetworking instead of Foundation for URLSession. Might be as simple as importing FoundationNetworking if canImport. Currently, Apollo fails to compile with warnings that URLSession has moved when trying to compile under Vapor Buildpack.

Repro, try to compile a target that imports apollo-ios package using Vapor Buildpack

       /tmp/build/.build/checkouts/apollo-ios/Sources/Apollo/HTTPResponse.swift:10:28: error: 'HTTPURLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
       public var httpResponse: HTTPURLResponse
       ^~~~~~~~~~~~~~~
       Foundation.HTTPURLResponse:2:18: note: 'HTTPURLResponse' has been explicitly marked unavailable here

(and many more)

Describe the solution you'd like

Looking into a conditional import of the framework to see if that's enough to fix it. Might be that there are incompatibilities as well.

@BadPirate BadPirate added the feature New addition or enhancement to existing solutions label Jul 11, 2024
@BadPirate BadPirate changed the title Use ApolloClient in Vapor Server environment 5.10.1 toolchain Use ApolloClient with swift-corelibs-foundation 5.10.1 Jul 11, 2024
@AnthonyMDev
Copy link
Contributor

Thanks for the report. Officially, Apollo iOS does not currently support Linux or server-side use cases. That said, if there is a simple way to make this work for your use case, we are open to a pull request to unblock you.

We aren't rejecting this issue, but it's not a high-priority for us right now. If you'd like to see this move forward, please consider making a PR yourself. Thank you!

@AnthonyMDev AnthonyMDev added the Linux Issues specific to use (or at least attempted use) on Linux label Jul 11, 2024
@BadPirate
Copy link
Author

@AnthonyMDev - Thanks! Yeah, chugging along here, seems that beyond some slight changes to URLSession (to use the FoundationNetwork stuff), the bigger issue is ApolloWebSocket, which relies on a few non-ported foundation libraries.

I've resolved zlib, and CommonCrypto here - https://github.com/BadPirate/apollo-ios/tree/badpirate/3410-FoundationNetworking (roughly, not ready for a PR, and might actually have some side effects even if it builds on Mac)

But the big holdout now seems to be SSL support :/ -- There doesn't seem to be a drop-in replacement for Apple's SSL stuff (nor would you want to make one as it's pretty long in the tooth) -- I think if I want web socket support (which I do) I'm going to have to re-implement using swift-nio or something. Do you see any lighter way to accomplish this?

@AnthonyMDev
Copy link
Contributor

@BadPirate We are planning on dropping support for some older iOS versions in the 2.0 version (currently in development). This should make it easier for us to then fix some of the SSL and web socket code. But it's still likely going to be a pretty big lift to re-implement WebSockets.

I do think you'll need to do some custom implementation for WebSockets, but I'd be interested in any work you're doing for linux support in the other areas for the 2.0 release. Would love to chat more about that and see a PR once I've got the 2.0 branch stable.

@BadPirate
Copy link
Author

Yeah, I'm trying to use ApolloClient with a server (and importantly subscriptions), perhaps being too clever, but I'm hoping to use server that has a subscription to a particular query on the DB as a "worker". At the moment I'm focused on getting it to work and running with Mac hardware, but very likely will be making a transition to linux once that is done, Apollo being the biggest hurdle, probably in a few months. I'll circle back then when I'm cracking on it.

@BadPirate
Copy link
Author

BadPirate commented Aug 12, 2024

Side note, I did an experiment to do the same thing (Apollo Client from server) using node / typescript -- and decided not to go that route as I want to have strictly typed code generated query results, and best I can tell the ApolloLink stuff only has that for React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions Linux Issues specific to use (or at least attempted use) on Linux
Projects
None yet
Development

No branches or pull requests

2 participants