Skip to content

org.springframework.graphql.test.tester.DefaultGraphQlTester allow access to raw response json #1164

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

Open
s-weller opened this issue Mar 21, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@s-weller
Copy link

s-weller commented Mar 21, 2025

My project has a parameterized test where I pass an input graphql query file location and a response json file location as arguments, and use the DefaultGraphQlTester to validate test queries

This works great, except for the fact that my application has a couple of composite mutations where I create a parent and child object in the same request, and for those I'd really just like access to the entire json response document to check manually instead of having to give a path relative to the top level "data" path.

What we curerently have

graphQLTester.execute(document)
   .path(relativePathFromDataNode)
   .matchesJson(expectedJson);

What I would like

graphQLTester.execute(document)
   .jsonBody() 
   .matchesJson(expectedJson);

Not picky about the syntax, I would just rather be able to compare a response like this:

{
  "data": {
    "createParent": {
      ... parent fields...
      },
   "createChild": {
      ... child fields ...
     }
  }
}

to a matching json document. Currently, I can supply '*' to the path argument in the first query, but that generates a list of nodes to match against

[
   {
      ... parent fields...
   },
   {
      ... child fields...
   }
]

which I feel is less intuitive than just allowing us access to the full json body when we need it. Thanks for your time and consideration, appreciate all the work you guys do.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants