Hello all!
I'm trying to port my REST api to graphql and everything is going well so far. I have few associated models that can be fetched using graphql.
However, after adding another one (in the same way as the other working ones), graphql-ruby is throwing an exception
NoMethodError - undefined method `edge_nodes' for #<Photo::ActiveRecord_Associations_CollectionProxy:0x007fc4bca360f0>
Here are my files:
LunchType = GraphQL::ObjectType.define do
name "Lunch"
field :photos, PhotosField
end
PhotosField = GraphQL::Field.define do
name 'photos'
type PhotoType.connection_type
resolve(PhotosResolver.new)
end
class PhotosResolver
def call(obj, _args, _ctx)
obj.photos
end
end
And running a following query:
query {
lunches {
edges {
node {
id
photos {
edges {
node {
id
}
}
}
}
}
}
}
Raises that exception mentioned above. Can anyone point me on what that actually means and how to debug what's happening? Important thing is that i have exact the same relations/connections (1-n) defined in the exact same way and they are working fine.
Thanks in advance!
I think you should change from:
field :photos, PhotosField
to:
connection :photos, PhotosField
Does that help?
Yes, totally. I'm not sure why i didn't tried that in first place. Thanks for your support!
Most helpful comment
I think you should change from:
to:
Does that help?