Code Monkey home page Code Monkey logo

Comments (2)

kaqqao avatar kaqqao commented on May 18, 2024

@Batched in SPQR provides the same semantics as that annotation already provides in graphql-java (note that it belongs to a graphql-java package, not SPQR). It provides a simple batching model that maps well to SQL (and some other) backends. It works with BatchedExecutionStrategy only.

Dataloader offers a very different strategy. To use dataloader, you must write the batch loader functions yourself and then change your logic to fetch data through the dataloader instead of directly. Unlike the previous model, it's not down to the execution strategy, but down to how you write your datafetchers. SPQR doesn't know what your methods do, so you need to change your own code to use the dataloader.

You might want to create a DataLoaderRegistry per request, and stick into the global context. This way you can easily inject it into your resolver methods via @GraphQLRootContext. Or, since you're using Spring, make DataLoaderRegistry a request scoped bean that you inject into your service classes.
You must also make sure to register a DataLoaderDispatcherInstrumentation to dispatch the batch jobs. But this is all completely external to SPQR.

Keep in mind, SPQR only really deals with assembling the schema and wiring your methods as datafetchers. Actually executing the queries you do using graphql-java directly.

from graphql-spqr.

kaqqao avatar kaqqao commented on May 18, 2024

You can see a simple example of using @Batched in BatchingTest

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.