django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

Inconsistent Documentation Regarding Resolver

Open leench opened this issue 1 year ago • 3 comments

I noticed in the Defining a Schema that it mentions using regular methods for resolvers. However, during testing, I encountered an error: NotImplementedError: Non static resolves are not supported yet.

Additionally, I found in the What's new in V1 section that it states: resolve_xxx(self, ...) - support resolve with (self) is dropped in favor of pydantic build-in functionality

Does this mean the old resolver method is no longer supported? If so, does the documentation need updating to reflect this change?

leench avatar Aug 16 '24 17:08 leench

It looked like a cool feature. I figure they might have dropped it in favor of using the context object? (Not sure if you can get the other attributes from it)

But the main thing for me is.. it could save you from adding @staticmethod to every resolver 😅 That's 1 less line every time.

MisaoDev avatar Sep 09 '24 00:09 MisaoDev

The documentation is def a bit lackluster - it says dropped in favour of built-in functionality but doesn't say which / link to documentation.

jleclanche avatar Sep 23 '24 10:09 jleclanche

Any updates on this? What is the advantage of staticmethod over traditional instance methods in this case? If one field is already computed and is available on the instance, it's better to use it directly if required for other field instead of re-doing

kanishk619 avatar Apr 28 '25 06:04 kanishk619