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

GraphQlTester does not pass extensions for subscriptions #1135

Open
rstoyanchev opened this issue Feb 21, 2025 · 0 comments
Open

GraphQlTester does not pass extensions for subscriptions #1135

rstoyanchev opened this issue Feb 21, 2025 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@rstoyanchev
Copy link
Contributor

From #1131 (comment).

Extensions don't get included in WebSocket requests made with the GraphQlTester.

Minimal example:

@Test
fun testSubscription() {
    val client = StandardWebSocketClient()
    // spring-graphql instance running on port 61686
    val tester = WebSocketGraphQlTester
        .builder("ws://localhost:61686/graphql", client)
        .build()

    val query = "subscription TestSubscription(\$accessCode: String!) { testSubscription(accessCode: \$accessCode) }"
    val subscription = tester
        .document(query)
        .variable("accessCode", "testAccessCode")
        .extension("x-test-extension", "testExtension")
        .executeSubscription()
        .toFlux()

    StepVerifier
        .create(subscription)
        .expectNextMatches {
            it.path("testSubscription").entity(String::class.java).get() == ""
        }
        .thenCancel()
        .verify()
}

The test passes, but the server doesn't receive any extensions. It appears that this is caused by the AbstractGraphQlTesterBuilder which doesn't pass in extensions before executing its subscription.

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

No branches or pull requests

1 participant