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

Is there a plan in place for adding support for async await? #55

Closed
cshadek opened this issue Mar 31, 2021 · 15 comments
Closed

Is there a plan in place for adding support for async await? #55

cshadek opened this issue Mar 31, 2021 · 15 comments

Comments

@cshadek
Copy link
Contributor

cshadek commented Mar 31, 2021

Async-await will be added in Swift 5.5.
https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md

@cshadek cshadek changed the title Is there a plan in place for adding support for async await when it is released in Swift 5.5? Is there a plan in place for adding support for async await? Mar 31, 2021
@cshadek
Copy link
Contributor Author

cshadek commented Sep 24, 2021

Given that Swift 5.5 is now released, will Graphiti support async-await?

@cshadek cshadek closed this as completed Nov 4, 2021
@alobaili
Copy link

Hello @cshadek, @paulofaria and @adam-fowler
For organization, I think this issue should be reopened and linked to #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!

@paulofaria
Copy link
Member

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.

@paulofaria
Copy link
Member

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.

@cshadek
Copy link
Contributor Author

cshadek commented May 24, 2022

@paulofaria have you given any thought as to how subscriptions and directives fit into the new API design?

@NeedleInAJayStack
Copy link
Member

@cshadek I have done a little thinking about subscriptions and async/await. The new AsyncSequence should be able to replace reactive drivers like GraphQLRxSwift.

@NeedleInAJayStack
Copy link
Member

NeedleInAJayStack commented May 24, 2022

@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
Copy link
Contributor Author

cshadek commented May 24, 2022

@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

@cshadek cshadek reopened this May 25, 2022
@cshadek
Copy link
Contributor Author

cshadek commented Jun 6, 2022

I just came across this, but it looks like this repo is already doing a lot of what we're talking about.

https://github.com/d-exclaimation/pioneer

@NeedleInAJayStack
Copy link
Member

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.

@cshadek
Copy link
Contributor Author

cshadek commented Jun 6, 2022

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!

@cshadek
Copy link
Contributor Author

cshadek commented Jun 6, 2022

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.

@NeedleInAJayStack
Copy link
Member

NeedleInAJayStack commented Jul 14, 2022

I have an PR in to GraphQL that adds async/await support, and a followup one ready for Graphiti once that one goes through.

@d-exclaimation
Copy link
Member

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.

@NeedleInAJayStack
Copy link
Member

I'm marking this as resolved, since async/await support was added by #78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants