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 integration for flask and quart #149

Closed
davidroeca opened this issue Sep 13, 2019 · 9 comments
Closed

Add integration for flask and quart #149

davidroeca opened this issue Sep 13, 2019 · 9 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@davidroeca
Copy link
Contributor

Any plans for implementations targeting flask or quart?

Alternatively, is there a standard way a third party could write a plugin for strawberry that targets an alternative framework? Asking because I like the design of strawberry models, but switching the entire framework leads to a pretty big migration rather than just swapping out graphene.

@davidroeca
Copy link
Contributor Author

🤦‍♂️ forgot that flask-graphql just targets a schema. Closing

@patrick91
Copy link
Member

@davidroeca I think it might still be worth adding a view like the one we did for Django, so you don't need to install another package for this :)

@patrick91 patrick91 reopened this Sep 13, 2019
@patrick91 patrick91 changed the title Implementations for flask/quart? Add integration for flask and quart Sep 13, 2019
@patrick91 patrick91 added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Sep 13, 2019
@johnchuks
Copy link
Contributor

johnchuks commented Sep 26, 2019

@patrick91 I would love to take a crack at this issue.

@patrick91
Copy link
Member

@johnchuks assigned to you! :)

@johnchuks
Copy link
Contributor

Awesome!

@cysabi
Copy link

cysabi commented Oct 1, 2019

Is there still help wanted for this?

@patrick91
Copy link
Member

Let's wait a couple of days for @johnchuks to answer :) otherwise I think you can work on this :)

@agritheory
Copy link

I asked about Strawberry + Quart over on the Quart gitter channel and Phil (Quart's author) had this interesting pattern:

class SplitMount:
    def __init__(self, base, extra, path):
        self.base = base
        self.extra = extra
        self.path = path

    async def __call__(self, scope, receive, send):
        if scope["path"].startswith(self.path):
            return await self.extra(scope, receive, send)
        else:
            return await self.base(scope, receive, send)

I was able to integrate Ariadne directly into a Quart blueprint, but that doesn't really let you write a class-based View (with GraphQL) the way one typically would in Quart or Flask app, nor with Strawberry's dataclass syntax or advantages. I like Ariadne's approach, but for my current project/ experiment, I'm only working with a handful of tables and views and it feels like using a screwdriver to pound in a nail. If I had lots (maybe even a few dozen) of views/tables/schemas to worry about, I think Ariadne's approach might be a better fit.

I'm not sure how you'd directly integrate Strawberry's ASGI pattern with Flask's WSGI architecture, so Phil's approach might be better for Flask than Quart. Haven't tried it.

@patrick91
Copy link
Member

I'll close this issue for now as we have a Flask view now. We can always add a Quart view later, if needed (not sure if it is different from Flask) :)

@catwell catwell mentioned this issue Oct 23, 2023
11 tasks
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

6 participants