Code Monkey home page Code Monkey logo

Comments (5)

jasl avatar jasl commented on May 9, 2024 1

Hi 👋

Do you need the resolver class? I'm wondering if you can just call the loader using a proc in the schema like this:

field "entity", EntityType, null: false, 
  resolve: -> (obj, args, context) { Loaders::RecordLoader.for(Entity).load(args["id"]) }

This implementation has worked for me in a couple of places and since the GQL docs seem to recommend against using a Resolver class, I think using the proc might be simpler and preferable.

I read the doc, but unfortunately I really need Resolvers, the code on topic is a simplified version.

from graphql-batch.

thetizzo avatar thetizzo commented on May 9, 2024

Hi 👋

Do you need the resolver class? I'm wondering if you can just call the loader using a proc in the schema like this:

field "entity", EntityType, null: false, 
  resolve: -> (obj, args, context) { Loaders::RecordLoader.for(Entity).load(args["id"]) }

This implementation has worked for me in a couple of places and since the GQL docs seem to recommend against using a Resolver class, I think using the proc might be simpler and preferable.

from graphql-batch.

sunhohong avatar sunhohong commented on May 9, 2024

Did you add this code to your schema?

use GraphQL::Batch

from graphql-batch.

jasl avatar jasl commented on May 9, 2024

@sunhohong just do a re-test, the problem solved, only different is I did a bundle update few days ago.

from graphql-batch.

SanskarSans avatar SanskarSans commented on May 9, 2024

RecordLoader.for(Entity).load(ids)
I see ids is used as an argument but what if I want to fetch all the records of Entity.

from graphql-batch.

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.