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

.preload not defined #20

Open
cassiopagnoncelli opened this issue Apr 7, 2019 · 3 comments
Open

.preload not defined #20

cassiopagnoncelli opened this issue Apr 7, 2019 · 3 comments

Comments

@cassiopagnoncelli
Copy link

Just included the gem into the bundle, installed it as per README instructions, and enabled it at class Schema.

Thing is, when I add preload to a type field, as in

Types::CustomerType = GraphQL::ObjectType.define do
  ...
  field :payments, !types[Types::PaymentType], preload: :payments
end

Error is as cumbersome as it gets:

GraphQL::Field can't define 'preload' excluded from capture: DSN not set

Using ruby-2.5.0 and rails-5.2.2. Ps: I think it is somewhat different from the other open issue as the error occurs at ObjectType level.

Can anyone shed a light here?

@ChrisKaun
Copy link

I guess it's just a syntax error. preload: :... need to be called in a block.

Types::CustomerType = GraphQL::ObjectType.define do
  ...
  field :payments, !types[Types::PaymentType] do
    preload: :payments
  end
end

@daemonsy
Copy link

daemonsy commented Sep 27, 2019

and if you're using the old block syntax, preload is a function. so its preload :payments and NOT preload: payments

@cassiopagnoncelli
Copy link
Author

Solved with a resolver,

field :payments, [Types::PaymentType], null: false, resolver: Resolvers::AssocCustomerPayments

simpler and (I hope) more stable syntax.

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

3 participants