Skip to content
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

on_schema_subscription needs to be a staticmethod? #345

Closed
GeoBSI opened this issue Jan 29, 2020 · 0 comments
Closed

on_schema_subscription needs to be a staticmethod? #345

GeoBSI opened this issue Jan 29, 2020 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@GeoBSI
Copy link

GeoBSI commented Jan 29, 2020

Issue

Tried implementing the on_schema_subscription as shown on the documentation: https://tartiflette.io/docs/api/directive

The app fails on _validate_directive_implementation(self) with the error message Directive Auth Method on_schema_subscription is not an Async Generator.

It works if I decorate the on_schema_subscription as a @staticmethod

Related issue: #346

Debug

Looking more in detail into the called method is_valid_async_generator(generator: AsyncGenerator), it receives my method as a
<bound method Auth.on_schema_subscription of <*******.directives.auth.auth object at 0x7f5a24a09610>>

The valid_async_generator of Tartiflette does:

isasyncgenfunction(
        generator if isfunction(generator) else generator.__call__
    )

Reproducing the logic gives:

# generator = my <bound method ****.on_schema_subscription>
isfunction(generator) = False
# so it tries with the generator.__call__
isasyncgenfunction(generator.__call__) = False

# but if I check by giving directly the generator without the isfunction check
isasyncgenfunction(generator) = True

So that explains my error

Reproduce it

Here's a simplified version of the code I'm testing issue-directive.zip

You can run it in an environment with the requirements installed with python -m src
It will fail to run if you don't remove the comment on @staticmethod in src.directives.Auth.on_schema_subscription

  • Tartiflette version: 1.1.1
  • Python version: 3.7
  • Executed in docker: No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants