Skip to content

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

Closed as not planned
@s-weller

Description

@s-weller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions