How do I use and access the operation name in a graphQL query using spring-boot-starter-graphql and GraphQlTester?

16 views Asked by At

This is what i am using in my intergration tests:

GraphQlTester.Response response = gqlTester
        .document("""
                    mutation updateSomething($id: ID!, $something: String!) {
                        updateName(
                            id: $id,
                            field: $something
                        ){
                        id
                        a
                        b
                      }
                    }
                """)
        .operationName("updateSomething")
        .variable("id", theId)
        .variable("something", "Something")
        .execute();

From what I understand, operation names are mandatory for multi-operation documents and can be used for logging in the backend.

a) How do I implement a multi-operation document in the GraphQlTester?

b) How do I use the operation name for logging in my spring-boot backend?

My resolver in the backend looks like this:

@MutationMapping
public ReturnValue updateName(@Argument String id, @Argument String something) {
    return myService.updateSomething(id, something);
}
0

There are 0 answers