Closed cshadek closed 1 year ago
Given that Swift 5.5 is now released, will Graphiti support async-await?
Hello @cshadek, @paulofaria and @adam-fowler For organization, I think this issue should be reopened and linked to https://github.com/GraphQLSwift/Graphiti/pull/71
It appears that support for async/await is a big undertaking. I really hope to see it implemented some day.
I've just started learning about this package from https://www.raywenderlich.com/21148796-graphql-tutorial-for-server-side-swift-with-vapor-getting-started
It's a great package, thank you all for your hard work!
Hi, thank you for your kindness. I will try to finish this by the end of the month. The async part itself is mostly done. It's just that I took the chance to improve the API so we can release a new major version and life got in the way.
I was also waiting on https://github.com/apple/swift-evolution/blob/main/proposals/0348-buildpartialblock.md to improve the API greatly. Instead of using classes and initializers for the Schema definition, we'll be able to use functions and structs, which will make the API look much closer to the GraphQL SDL.
@paulofaria have you given any thought as to how subscriptions and directives fit into the new API design?
@cshadek I have done a little thinking about subscriptions and async/await. The new AsyncSequence should be able to replace reactive drivers like GraphQLRxSwift.
@alobaili In the meantime, you can convert any EventLoopFuture
API to an async
one by using EventLoopFuture.get
. For example:
let result = await graphitiAPI.execute(
request: request,
...
).get()
@cshadek I have done a little thinking about subscriptions and async/await. The new AsyncSequence should be able to replace reactive drivers like GraphQLRxSwift.
This sounds amazing
I just came across this, but it looks like this repo is already doing a lot of what we're talking about.
Woah, I hadn't seen that repo before! That's pretty awesome stuff they're doing! Yeah, it seems like we could easily bring some of the extensions they've made into this repo.
Yeah I just found it earlier today. I really wonder if there shouldn't be some strategic partnership between Pioneer and GraphQLSwift. It's almost like they want to build Apollo Server for Swift - that would be incredible!
It does seem like it's only one guy - which is not unheard of it, but I'd worry about it getting maintained longterm. But some of the stuff with abstracting away the web socket support and graphiQL is really nice.
I have an PR in to GraphQL that adds async/await support, and a followup one ready for Graphiti once that one goes through.
Woah, I hadn't seen that repo before! That's pretty awesome stuff they're doing! Yeah, it seems like we could easily bring some of the extensions they've made into this repo.
I think I can help move the async-await extensions I made from Pioneer here. The only problem with those extensions I made is that at the moment, they completely ignore the Sendable conformance which is not enforced now with Swift 5 but will be a problem later on with Swift 6 which is set to be safe-by-default and the only solution I see is @_unsafeSendable
attribute but I haven't played with it yet.
I'm marking this as resolved, since async
/await
support was added by https://github.com/GraphQLSwift/Graphiti/pull/78
Async-await will be added in Swift 5.5.
https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md