ariadne
ariadne copied to clipboard
Callable fields require one extra argument for info object
Per documentation, this should work:
type_def = """
type User {
username: String!
likes: Int!
initials(length: Int!): String
}
"""
class UserObj:
username = "admin"
def likes(self):
return count_user_likes(self)
def initials(self, length):
return self.username[:length]
However, when I ran this example and tried making a query like this:
{
user {
likes
}
}
I got an error:
likes() takes 1 positional argument but 2 were given
When I changed likes method to be:
def likes(self, info)
it seemed to work.
Suggested fix: callable fields don't require an extra argument
Originally posted by @heikkiket in https://github.com/mirumee/ariadne/discussions/691