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

feature: GraphQL execution for @defer support #413

Merged
merged 36 commits into from
Jul 19, 2024

Conversation

calvincestari
Copy link
Member

@calvincestari calvincestari commented Jul 2, 2024

This PR is to merge the @defer required changes to the GraphQL executer into main. There is already some of the @defer work in the main branch but we chose to build the executor changes on a separate branch in isolation not to cause any instability to main.

This PR should only consist of other PRs that have already been reviewed and merges from main to keep this branch up-to-date with main.

calvincestari and others added 30 commits November 20, 2023 11:33
# Conflicts:
#	apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
# Conflicts:
#	apollo-ios-codegen/Sources/GraphQLCompiler/JavaScript/src/__tests__/deferDirectiveTests.ts
# Conflicts:
#	apollo-ios-codegen/Sources/ApolloCodegenLib/Templates/SelectionSetTemplate.swift
# Conflicts:
#	apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
#	apollo-ios/Sources/Apollo/FieldSelectionCollector.swift
#	apollo-ios/Sources/Apollo/GraphQLExecutor.swift
#	apollo-ios/Sources/Apollo/GraphQLSelectionSetMapper.swift
# Conflicts:
#	Tests/ApolloInternalTestHelpers/InterceptorTester.swift
#	apollo-ios/Sources/Apollo/DefaultInterceptorProvider.swift
#	apollo-ios/Sources/Apollo/GraphQLExecutor.swift
#	apollo-ios/Sources/Apollo/MultipartResponseDeferParser.swift
#	apollo-ios/Sources/Apollo/MultipartResponseParsingInterceptor.swift
#	apollo-ios/Sources/Apollo/MultipartResponseSubscriptionParser.swift
# Conflicts:
#	apollo-ios/Sources/Apollo/GraphQLResult.swift
# Conflicts:
#	apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
Copy link

netlify bot commented Jul 2, 2024

Deploy Preview for apollo-ios-docc canceled.

Name Link
🔨 Latest commit 6b78529
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docc/deploys/669aae20d477b40008899c66

Copy link

netlify bot commented Jul 2, 2024

Deploy Preview for eclectic-pie-88a2ba ready!

Name Link
🔨 Latest commit 6b78529
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-pie-88a2ba/deploys/669aae20c2d39a00086d31be
😎 Deploy Preview https://deploy-preview-413--eclectic-pie-88a2ba.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@calvincestari calvincestari changed the title feature: @defer feature: GraphQL execution for @defer support Jul 3, 2024
@john-twigg-ck
Copy link

john-twigg-ck commented Jul 17, 2024

@calvincestari

I'd like to provide feedback about the the way I would expect to be able to leverage the @Deferred property.

The ability to introspect the status of pending vs fulfilled is useful, however as an end user I would like to be able to await on a pending state and eventually receive the final result.

pseudo example taken from here

      expect(animal.fragments.$deferredGenus).to(equal(.pending))
        
      let genus = try await animal.fragments.$deferredGenus 
        
      expect(animal.fragments.$deferredGenus).to(equal(.fulfilled)) //its now finished
      expect(animal.fragments.deferredGenus).toBeNonNil() //its non nil
      expect(animal.fragments.deferredGenus).to(equal(genus)) 

NOTE: I'd expect something similar with @stream where I could receive an AsyncStream

@calvincestari
Copy link
Member Author

Hi @john-twigg-ck, thanks for the feedback.

The ability to introspect the status of pending vs fulfilled is useful, however as an end user I would like to be able to await on a pending state and eventually receive the final result.

The implementation of @defer is built on the existing network stack which unfortunately does not have any async/await support. So awaiting on the status won't be possible in 1.x. @AnthonyMDev is currently working on Swift 6 compatibility which will be a major version bump, and will include proper support for async/await too so it's possible that in the future we could get that working but it's still got some challenges though due to the way that the models and data is handled, i.e.: models and their data are not persisted so there is nothing to 'update'.

NOTE: I'd expect something similar with @stream where I could receive an AsyncStream

There's only bad news here I'm afraid as unfortunately there is no existing support for @stream, and it's not in this implementation either. I don't think any of the Apollo clients support @stream nor does the Apollo Router. Eventually when the @defer/@stream proposal is merged into the GraphQL spec we'll have to provide support for it.

@calvincestari calvincestari mentioned this pull request Jul 19, 2024
8 tasks
@calvincestari calvincestari marked this pull request as ready for review July 19, 2024 18:27
@calvincestari calvincestari merged commit bfc13e5 into main Jul 19, 2024
34 checks passed
@calvincestari calvincestari deleted the feature/defer-execution-networking branch July 19, 2024 18:48
BobaFetters pushed a commit to apollographql/apollo-ios that referenced this pull request Jul 19, 2024
BobaFetters pushed a commit to apollographql/apollo-ios-codegen that referenced this pull request Jul 19, 2024
BobaFetters pushed a commit that referenced this pull request Jul 19, 2024
b73d4bb8 feature: GraphQL execution for `@defer` support (#413)

git-subtree-dir: apollo-ios
git-subtree-split: b73d4bb836ec44ea3536d506b2a354eed9986ea7
BobaFetters pushed a commit that referenced this pull request Jul 19, 2024
… support

git-subtree-dir: apollo-ios
git-subtree-mainline: 7f6d97b
git-subtree-split: b73d4bb836ec44ea3536d506b2a354eed9986ea7
BobaFetters pushed a commit that referenced this pull request Jul 19, 2024
90ab76be feature: GraphQL execution for `@defer` support (#413)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: 90ab76bef1f2d2003b3825851ebb23999ca9846c
BobaFetters pushed a commit that referenced this pull request Jul 19, 2024
…`@defer` support

git-subtree-dir: apollo-ios-codegen
git-subtree-mainline: 6351b65
git-subtree-split: 90ab76bef1f2d2003b3825851ebb23999ca9846c
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

Successfully merging this pull request may close these issues.

2 participants