Comments (7)
I believe we had the same issue and fixed it by setting:
generator.withScalarMappingStrategy(new MapScalarStrategy());
from graphql-spqr.
This will indeed change the way maps are treated, and will solve the immediate issue. Maps will be treated as complex scalar values (i.e. JSON blobs) and not transformed into lists of key-value pairs. But this means subselection is not possible (scalars are leaf types)...
from graphql-spqr.
@mjp91 @brettcooper @bpoussin
I was looking into what's needed to make Jackson deserialize maps when they're encoded as list of key-value pairs. It's doable, but quite complex. So I'm wondering if it's worth it.
In your use-cases so far, did you benefit from the current default behavior that represents maps as lists (preserving type-safety), or does the simple map-as-a-blob strategy offered by MapScalarStrategy
suffice?
from graphql-spqr.
@kaqqao we've got by treating them as scalars, would be nice to have the extra type safety and sub-selection but not a must
from graphql-spqr.
@kaqqao MapScalarStrategy() seems to serve our needs for the time being.
from graphql-spqr.
InputConverter
mechanism has been completely overhauled to attach itself to the Jackson/Gson deserialization logic to properly apply the conversions throughout the object hierarchy. This unfortunately imposes limitations on TYPE_USE
annotations on input fields (@GraphQLId
being the only relevant example) because not a single JSON library for Java supports AnnotatedType
as of yet.
Worth to note, maps are now treated as scalars by default, so the MapScalarStrategy
is now deprecated.
from graphql-spqr.
I solved the this JSON parse issue by replacing "Map<String, String> request" with "Map<String, Object> request"
@PostMapping(value = "/graphql", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public Map<String, Object> graphql(@RequestBody Map<String, Object> request, HttpServletRequest raw) {
ExecutionResult executionResult = graphQL.execute(ExecutionInput.newExecutionInput()
.query(request.get("query").toString())
.operationName(request.get("operationName") != null ? request.get("operationName").toString() : null)
.context(raw)
.build());
return executionResult.toSpecification();
}
from graphql-spqr.
Related Issues (20)
- Is it possible to set a description for a field of a type? HOT 6
- DefaultValue can't be converted when passed as separate values HOT 8
- JacksonValueMapper ignores annotations on private fields
- Setup GitHub Pages for documentation
- Apply bean validation annotations only if an appropriate group is enabled [Breaking]
- How to use executionResult data HOT 2
- Failing tests - ComplexityTest class
- Explicitly register Java classes to the GraphQL schema. HOT 4
- How to map a java class to GraphQL interface without using @GraphQLInterface annotation? HOT 5
- Best way to error handling HOT 1
- Help in Handling Exceptions with SPQR HOT 1
- Question: Extending an InputObject type and handle it in SPQR HOT 3
- SDL Printing Fails on Schema Directives with Arguments HOT 4
- Spring 3.2: Cannot resolve parameter names for constructor public io.leangen.graphql.spqr.spring.web.dto.GraphQLRequest(java.lang.String,java.lang.String,java.lang.String,java.util.Map) HOT 2
- Compile parameters to support Spring Boot 3.2.1 (Spring Framework 6.1) HOT 1
- null values sent in response json HOT 1
- Schema Generation Regression in 0.12.4 HOT 1
- Polymorphism type on input
- Scalars containing an Instant cannot be serialized over subscription
- Schema generation at compile time?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-spqr.