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.Response should expose extensions #1131

Open
nlemoing opened this issue Feb 18, 2025 · 3 comments
Open

GraphQlTester.Response should expose extensions #1131

nlemoing opened this issue Feb 18, 2025 · 3 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@nlemoing
Copy link

Hi, I recently implemented a feature which uses GraphQL Extensions and I'm trying to write a test which validates that they're being returned properly. It looks like extensions are available in the GraphQlResponse class but aren't available in the GraphQlTester.Response interface. Is there another way to access them, and if not, would it be possible to extend the interface to include extensions?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 18, 2025
@rstoyanchev rstoyanchev self-assigned this Feb 19, 2025
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 19, 2025
@rstoyanchev rstoyanchev added this to the 1.3.5 milestone Feb 19, 2025
@rstoyanchev
Copy link
Contributor

That's not possible at the moment indeed, and just a matter of exposing it through GraphQlTester.Response.

@nlemoing
Copy link
Author

Thanks for looking into this! I discovered another related issue today: it appears that extensions don't get included in WebSocket requests made with the GraphQL tester.

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.

@rstoyanchev rstoyanchev changed the title GraphQlTester.Response: Is there a way to get the response extensions? GraphQlTester.Response should expose extensions Feb 21, 2025
@rstoyanchev
Copy link
Contributor

Thanks, I've created a separate issue #1135 for that.

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

No branches or pull requests

3 participants