Closed heikkiket closed 8 months ago
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
likes() takes 1 positional argument but 2 were given
When I changed likes method to be: def likes(self, info) it seemed to work.
def likes(self, info)
Suggested fix: callable fields don't require an extra argument
Originally posted by @heikkiket in https://github.com/mirumee/ariadne/discussions/691
Documentation is incorrect here. We are using default resolver from the graphql-core, which has the info, **kwargs signature.
info, **kwargs
Per documentation, this should work:
However, when I ran this example and tried making a query like this:
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