Code Monkey home page Code Monkey logo

Comments (7)

brettcooper avatar brettcooper commented on May 18, 2024 1

I believe we had the same issue and fixed it by setting:
generator.withScalarMappingStrategy(new MapScalarStrategy());

from graphql-spqr.

kaqqao avatar kaqqao commented on May 18, 2024

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.

kaqqao avatar kaqqao commented on May 18, 2024

@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.

mjp91 avatar mjp91 commented on May 18, 2024

@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.

brettcooper avatar brettcooper commented on May 18, 2024

@kaqqao MapScalarStrategy() seems to serve our needs for the time being.

from graphql-spqr.

kaqqao avatar kaqqao commented on May 18, 2024

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.

kvzn avatar kvzn commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.