-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify documentation to be more clear about resolvers being static #952
Modify documentation to be more clear about resolvers being static #952
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allardhoeve decorating resolvers with @staticmethod
is not necessary but thanks for the change from self
Good suggestions, I'll apply them next week and then re-request the merge. I disagree about the necessity of
Of course you can ignore these standards, but they are confusing to code reviewers and to programmers new to GraphQL, such as myself. Lastly the methods are no longer callable from the outside of GraphQL without also using the unbind magic, because the signature no longer matches a method, because the I feel that the documentation for GraphQL should be as clear as possible and should reflect this rather odd unbinding of the resolver well, so new programmers are sure about the interface. You can of course always leave the decorator off you own functions if you want. To me this is a documentation issue. |
Change resolver examples to use better named arguments Co-Authored-By: allardhoeve <allardhoeve@gmail.com>
I disagree on needing static also because resolvers do not need to be defined next to the fields, but may be defined outside of, and may very well be for more complex ones. In that case, adding staticmethod makes it confusing. And doing it only for resolvers when defined with the field makes it inconsistent and confusing. |
Indeed, not every resolver needs to be a staticmethod. If you use an outside function as a resolver, then no, you definitely shouldn't use a decorator. But as defined in a class, they probably should be marked as such, as they are essentially functions after becoming unbound by GraphQL. My request is not at all to force everyone to use static method decorators everywhere, but just that we improve the documentation on resolvers better, because they are inconsistently documented currently. My suggestion is still that for resolvers that are defined on NodeType objects, we still document them as static methods, as they are. And the part in the documentation on resolvers is easily missed. But the situation improves with changing |
Is it possible to add a documentation note about this issue with some IDEs and leave the default examples without? Either way, we should progress this PR or close it. |
See #951