Skip to content

Allow future return type for subscription data fetcher #797

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

Merged
merged 2 commits into from
Apr 29, 2025

Conversation

oryan-block
Copy link
Collaborator

Fix oversight from #756. Allow subscription data resolvers to also return a CompletableFuture<Publisher>.

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables subscription data resolvers to return a CompletableFuture that wraps a Publisher, addressing an oversight from a previous PR.

  • Added tests to verify subscription resolver return types for future-wrapped publishers.
  • Enhanced end-to-end tests to execute subscription queries using the future-based approach.
  • Updated FieldResolverScanner to detect CompletableFuture return types.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/test/kotlin/graphql/kickstart/tools/SchemaParserTest.kt Added tests to validate error messages for invalid subscription resolver return types, including future-wrapped values.
src/test/kotlin/graphql/kickstart/tools/EndToEndTest.kt Introduced an end-to-end test for executing subscription queries that return a future-wrapped Publisher.
src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt Added new Subscription fields and methods to support future-based subscription resolvers.
src/main/kotlin/graphql/kickstart/tools/resolver/FieldResolverScanner.kt Updated the logic to check for CompletableFuture return types in resolver methods.
Comments suppressed due to low confidence (1)

src/test/kotlin/graphql/kickstart/tools/EndToEndSpecHelper.kt:385

  • Consider adding an onComplete() call after subscriber.onNext(...) inside the Publisher lambda if the intention is for the publisher to complete after emitting the event, to ensure proper stream termination.
fun onItemCreatedFuture(env: DataFetchingEnvironment): CompletableFuture<Publisher<Item>> {

@oryan-block oryan-block merged commit d302771 into master Apr 29, 2025
3 checks passed
@oryan-block oryan-block deleted the 334-allow-future-return-type branch April 29, 2025 19:06
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.

1 participant