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

Add DirectivesMiddleware to Django #162

Closed
patrick91 opened this issue Sep 26, 2019 · 5 comments
Closed

Add DirectivesMiddleware to Django #162

patrick91 opened this issue Sep 26, 2019 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@patrick91
Copy link
Member

Currently directives are not working when using the Django view, like we have done for the ASGI app:

92d8f5d#diff-d6a364f593ab251cd7ee3024456f07f5R17-R44

@patrick91 patrick91 added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers Hacktoberfest labels Sep 26, 2019
@parikshitgupta1
Copy link

parikshitgupta1 commented Oct 1, 2019

Are the directives active now?
92d8f5d#diff-d6a364f593ab251cd7ee3024456f07f5R17-R44

####middelware.py
Duplicate of #
`from .directive import DIRECTIVE_REGISTRY

class DirectivesMiddleware:
def resolve(self, next_, root, info, **kwargs):
result = next_(root, info, **kwargs)

    for directive in info.field_nodes[0].directives:
        directive_name = directive.name.value

        func = DIRECTIVE_REGISTRY.get(directive_name)

        arguments = {
            argument.name.value: argument.value.value
            for argument in directive.arguments
        }

        result = func(result, **arguments)

    return result`

@patrick91
Copy link
Member Author

@parikshitgupta1 no :) the execute function linked there is only used in the ASGI middleware, but not in django, see here:

https://github.com/strawberry-graphql/strawberry/blob/master/strawberry/contrib/django/views.py#L52

we need to make a custom graphql_sync I think :)

@un33k
Copy link

un33k commented Oct 15, 2019

@patrick91 please have in mind that Django 3.0 is around the corner. With full async support, as per their roadmap

@patrick91
Copy link
Member Author

@un33k I think django 3.0 won't support async views. Support for that will arrive later :)

@patrick91
Copy link
Member Author

This has been done for a while, closing :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants