Skip to content

fail to GET request with variables #58

Open
@ttyniwa

Description

@ttyniwa

reported at #52 (comment)

Currently the transmission of variables in the request via puery param does not work either. When I send a request (as defined in the docu https://graphql.org/learn/serving-over-http/), the following error occurs

Field error in object 'graphQLRequest' on field 'variables': rejected value [{
"$content": "123"
}]; codes [typeMismatch.graphQLRequest.variables,typeMismatch.variables,typeMismatch.java.util.Map,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [graphQLRequest.variables,variables]; arguments []; default message [variables]]; default message [Failed to convert value of type 'java.lang.String[]' to required type 'java.util.Map'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String[]' to required type 'java.util.Map': no matching editors or conversion strategy found]]

	@Test
	public void defaultControllerTest_GET_with_variables() throws Exception {
		mockMvc.perform(
				get("/"+apiContext)
						.param("query","query echo($content: String) {echo(content: $content)}")
						.param("variables", "{\n" +
                                "  \"$content\": \"123\"\n" +
                                "}")
						)
				.andExpect(status().isOk())
				.andExpect(content().string(containsString("Hello world")));
	}

reason: Jackson databiner doesn't know how to convert String to Map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions