Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize question #86

Closed
razertory opened this issue Jun 11, 2018 · 1 comment
Closed

optimize question #86

razertory opened this issue Jun 11, 2018 · 1 comment

Comments

@razertory
Copy link

In graphql-ruby, I've found that every single field of a type is not asynchronizly resolved

# the sleep method represents any blocking method call or IO
field :a, types.String do 
    resolve -> (o, args, c) {
      sleep 3
      "a"
    }
  end

  field :b, types.String do 
    resolve -> (o, args, c) {
      sleep 3 
      "b"
    }
  end

  field :c, types.String do 
    resolve -> (o, args, c) {
      sleep 3 
      "c"
    }
  end

  field :d, types.String do 
    resolve -> (o, args, c) {
      sleep 3 
      "d"
    }
  end

if a query like

test {
    a
    b
    c
    d
  }

the time cost could be

Completed 200 OK in 12602ms (Views: 0.6ms)

seems like the time cost is 3 * 4 = 12 second
I want to get the field concurrently, then the time cost could be nearly 3 second. Is it a good way to use your gem ? Or I should submit a new issue in graphql-ruby 😂

@dylanahsmith
Copy link
Contributor

graphql-ruby support Lazy Execution which sounds like what you want. If you don't need batching, then I would just use that directly. That Lazy Execution feature was an extraction from this gem and thus is used by this gem.

If you decide to use this gem for batching but want to load the batch queries concurrently, then #45 is the relevant issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants