Hi, please excuse what is probably a ridiculous question - have been experimenting with a new API for an existing rails app and have hit some roadblocks.
I'm trying to create a connection in an account type:
AccountType = GraphQL::ObjectType.define do
name "Account"
description "Authenticated user entry, returns all information"
#...
connection :payments, PaymentType.connection_type do
resolve ->(user, args, ctx) {
TransactionFinder.private_for(user)
}
end
end
TransactionFinder returns an AR::Relation of Payment records. I was hoping that would use this type:
PaymentType = GraphQL::ObjectType.define do
name "Payment"
description "Fulfilled payments"
#...
field :description, types.String, "Description of the payment"
end
However when I try to access it:
{
account {
payments { description }
}
}
I get this error:
{
"errors": [
{
"message": "Field 'description' doesn't exist on type 'PaymentConnection'",
"locations": [
{
"line": 3,
"column": 16
}
],
"fields": [
"query",
"account",
"payments",
"description"
]
}
]
}
I was hoping it would use the field from the PaymentType. There's no PaymentConnection type other than what has been dynamically defined in the above code.
Any ideas as to what (no doubt incredibly obvious) thing I'm doing wrong?
Thanks a lot!
Excuse the noise. The act of typing this issue up made me realise what I was doing wrong. Of course, I have to do:
{
account {
payments {
edges {
node {
description
}
}
}
}
}
Unfortunately I realised this about 60 seconds after hitting send. Thanks anyway :)
Glad you tracked it down!
@jtippett thx, just spent 3 hours :))
Most helpful comment
Excuse the noise. The act of typing this issue up made me realise what I was doing wrong. Of course, I have to do:
Unfortunately I realised this about 60 seconds after hitting send. Thanks anyway :)