|
1 | 1 | package graphql.servlet.internal; |
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.core.JsonParser; |
| 4 | +import com.fasterxml.jackson.core.ObjectCodec; |
4 | 5 | import com.fasterxml.jackson.core.type.TypeReference; |
5 | 6 | import com.fasterxml.jackson.databind.DeserializationContext; |
6 | 7 | import com.fasterxml.jackson.databind.JsonDeserializer; |
7 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
8 | 8 |
|
9 | 9 | import java.io.IOException; |
10 | 10 | import java.util.Map; |
|
15 | 15 | public class VariablesDeserializer extends JsonDeserializer<Map<String, Object>> { |
16 | 16 | @Override |
17 | 17 | public Map<String, Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
18 | | - return deserializeVariablesObject(p.readValueAs(Object.class), (ObjectMapper) ctxt.findInjectableValue(ObjectMapper.class.getName(), null, null)); |
| 18 | + return deserializeVariablesObject(p.readValueAs(Object.class), p.getCodec()); |
19 | 19 | } |
20 | 20 |
|
21 | | - public static Map<String, Object> deserializeVariablesObject(Object variables, ObjectMapper mapper) { |
| 21 | + public static Map<String, Object> deserializeVariablesObject(Object variables, ObjectCodec codec) { |
22 | 22 | if (variables instanceof Map) { |
23 | 23 | @SuppressWarnings("unchecked") |
24 | 24 | Map<String, Object> genericVariables = (Map<String, Object>) variables; |
25 | 25 | return genericVariables; |
26 | 26 | } else if (variables instanceof String) { |
27 | 27 | try { |
28 | | - return mapper.readValue((String) variables, new TypeReference<Map<String, Object>>() {}); |
| 28 | + return codec.readValue(codec.getFactory().createParser((String) variables), new TypeReference<Map<String, Object>>() {}); |
29 | 29 | } catch (IOException e) { |
30 | 30 | throw new RuntimeException(e); |
31 | 31 | } |
|
0 commit comments