Closed sandergroen closed 7 years ago
@sandergroen I am glad you found it useful. Lets see, oh right so you see the first line in your code,
connection = GraphQL::Relay::RelationConnection.new(viewer, {})
You are passing viewer as first argument, but it should be the contacts
collection object. This class basically takes a collection to create a connection between an existing collection and new edge (which is a new contact record). See the documentation here, https://rmosolgo.github.io/graphql-ruby/relay/connections#connection-objects (second snippet)
@gauravtiwari thanks a lot that did the job. You're the best!
@gauravtiwari thanks for the tutorial it helped me to get started with Relay and GraphQL on rails. I am implementing an application that uses bits and pieces of your example code. But now I have an issue with the mutation code. In my case I create a new Contact record and I'm using the following snipped in my mutation code:
And then when post a new contact item I get the following error: undefined method `offset' for #<struct Viewer id={:id=>"root"}>
Digging into the RelationConnection code I see the following code that I think is causing the error:
The Viewer class you added does not have an offset or limit method. Do you have any ideas how to solve this issue? Thanks!