Skip to content

GraphQlTester does not pass extensions for subscriptions #1135

Closed
@rstoyanchev

Description

@rstoyanchev

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions