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

bug: "extensions" exposed in valid graphQL request #1278

Closed
antholeole opened this issue Oct 18, 2022 · 2 comments
Closed

bug: "extensions" exposed in valid graphQL request #1278

antholeole opened this issue Oct 18, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@antholeole
Copy link
Contributor

antholeole commented Oct 18, 2022

Steps to reproduce

Run the default DGS app with the following query:

query {
  hello
}

or a mutation:

mutation {
  addRating(input: {
    title: "Dahmer",
    stars: 1 # 2 scary 4 me
  }) {
    avgStars
  }
}

Expected behavior

the server should respond with:

{
  "data": {
    "hello": "hello, Stranger!"
  }
}

or

{
  "data": {
    "addRating": {
      "avgStars": 1
    }
  }
}

Actual behavior

the server responds with:

{
  "data": {
    "hello": "hello, Stranger!"
  },
  "extensions": {}
}

or:

{
  "data": {
    "addRating": {
      "avgStars": 1
    }
  },
  "extensions": {}
}

I ran a git bisect and narrowed it down to commit 3cab92c3172128b37c277e89d491df3fe108bc12. I can try to fix it after I'm done with refactor-metrics, unless someone beats me to it.

I didn't test for subscriptions but it's probably happening there too.

@antholeole antholeole added the bug Something isn't working label Oct 18, 2022
@antholeole
Copy link
Contributor Author

Actually looking back at this, this is not really a bug - it's leftover from DGS_RESPONSE_HEADERS_KEY getting removed from extensions.

I'll leave this open if you want me to fix it during my next PR, otherwise I'll close. Test case is easy, just add this to the test added during that PR:

        ...
        assertThat(result.headers["myHeader"]).contains("hello")

        assertThat(result.body).isInstanceOfSatisfying(ByteArray::class.java) { body ->
            val mapper = jacksonObjectMapper()
            val (_, _, extensions) = mapper.readValue(body, GraphQLResponse::class.java)
            assertThat(extensions).isNull()
        }

@paulbakker
Copy link
Collaborator

paulbakker commented Oct 19, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants