swift-graphql
swift-graphql copied to clipboard
Linux support
Is your feature request related to a problem? Please describe. It would be nice to have the library available on Linux too, e.g. to use the GraphQL client in server-sided applications.
Describe the solution you'd like Add support for Linux by...
- dropping dependencies on Apple-specific frameworks (like
Combine
) - adding conditional
FoundationNetworking
imports, sinceURLSession
is not part of the cross-platformFoundation
anymore - migrating to an open-source WebSocket client framework (e.g.
websocket-kit
), sinceURLSessionWebSocketTask
is only available on Apple platforms - adding
LinuxMain.swift
andXCTestManifests.swift
to the test modules so the unit tests run on Linux too (an example of the test module structure can be found here)
We could make the Selection.serialize function public so people can use SwiftGraphQL on their own network layer.
@fwcd would that make integrating the library with apple code more complicated (i.e. would it require additional steps to include custom frameworks as compared to now)?
I've actually been looking into platform support this past week. I recognise this is an old issue, but I also think we might have some options that would enable this.
To address @maticzav's concern, I agree we don't want to do that. But I think there could be options depending on how we structure packages.
I don't know the internals well enough yet, but as a broad idea, I believe we could include platform-agnostic code in a Core library. Then have the platforms code in a library similar to what we have now, but automatically depending on the new core.
Linux libraries could then be added that build on core.
I also like this idea even for platforms. I'd prefer to have "convenience" but still have options for injecting my own network stack since when integrating with an existing app for example, it would be common to already have a lot established networking layer, caching, logging, etc... that would be thus easier to integrate with.
I'd like to close this issue for now. But I'll start a new discussion so we can continue to discuss requirements and options there. This would likely be planned for v6 anyway, so a larger discussion makes more sense imo 👍