Code Monkey home page Code Monkey logo

Comments (2)

jlouis avatar jlouis commented on August 23, 2024

We've wanted to have dataloader-like capabilities for some time, but it is dependent on having full concurrency support in the code base (which currently needs some timeout handling code). Indeed, once that is in, the plan is to have a hook-like functionality where you can register a small function to be run (usually you will use it to send a message).

The concurrency-work is not documented yet, mostly because it is highly experimental and still subject to change. But indeed, the defer_loop function is the place where you want some kind of hook in order to tick and tell a data loader process to execute its batch of work.

from graphql-erlang.

bullno1 avatar bullno1 commented on August 23, 2024

We may need this feature soon because certain nested queries with shared nodes are performing terribly.

The batch start hook should be in Ctx just like error_mod. For extensibility, I think it should be a module just like error. The key can be something like concurrency_mod or batch_mod.
hook:begin_loop(Ctx) should kick the data loader process and defer_hook:end_loop(Ctx) can do some clean up if necessary.

For actual implementation, I'm not sure what's the right thing to do. Here's what I have in mind.
Wrap this call: https://github.com/shopgun/graphql-erlang/blob/8e75a73892a97f43e142fabf04599acebea8eb95/src/graphql_execute.erl#L105

with Hook:begin_loop(Ctx) and Hook:end_loop(Ctx). Maybe a with a try finally to ensure end_loop is always called.
I'm not sure how error in begin_loop and end_loop should be handled, probably just like resolver_crash.

Any inputs on this?

from graphql-erlang.

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.