Skip to content

Databind-error on simple jsonMapper.writeValueAsString() #241

Description

@FrankMeissnerXledger

Hello, while trying to get something useful from a weird response coming from an graphql-server, I met another obstacle.

Am I doing something wrong here? My intention was to write qrr, regardless of what fields it might or might not contain. The error the tests generates is the same as the one I got from my production-code (I used another QueryRootResponse, it was generated by graphql-maven-plugin).

The test was written in the graphql-java-client-runtime-project, since that's where com.graphql_java_generator.client.response.Error is located.

package com.graphql_java_generator.client.response;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import com.graphql_java_generator.domain.client.forum.QueryRootResponse;

import tools.jackson.databind.json.JsonMapper;

@ExtendWith(MockitoExtension.class)
public class ErrorTest {

	@Test
	void simple() throws Exception {
		final JsonMapper jsonMapper = new JsonMapper();
		final QueryRootResponse qrr = jsonMapper.readValue("""
			{
			  "errors": [
			    {
			      "message": "some error message"
			    }
			  ]
			}""", QueryRootResponse.class);
		
		jsonMapper.writeValueAsString(qrr);
	}
}

The test fails in the branch graphql-maven-plugin-project-4.0.2 with:

[ERROR] Errors: 
[ERROR]   ErrorTest.simple:26 » Databind Cannot invoke "java.util.Map.keySet()" because "this.extensionsAsMapOfJsonNode" is null
 at [No location information] (through reference chain: com.graphql_java_generator.domain.client.forum.QueryRootResponse["errors"]->java.util.ArrayList[0]->com.graphql_java_generator.client.response.Error["extensionsAsMapStringString"])

Greetings, Frank Meissner

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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