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

Stop micromanaging WS support in IDEs #3660

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented Oct 6, 2024

Description

This PR removes the subscriptions_enabled flag from the Django and Channels views. It also removes two internal flags with the same purpose from all other views.

These flags were originally added to address #334. However, the behavior described in that issue has since been changed in GraphiQL, making our flag useless. (Tested locally using the Django integration, setting subscriptions_enabled to true, opening GraphiQL, and observing the browser's network tab).

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Summary by Sourcery

Remove the subscriptions_enabled flag from various views and update the documentation accordingly. Enable WebSocket support by default in all GraphQL IDEs, simplifying the configuration process.

Enhancements:

  • Remove the subscriptions_enabled flag from Django and Channels views, as well as from other internal views, to simplify the configuration and enable WebSocket support by default.

Documentation:

  • Update the documentation to reflect the removal of the subscriptions_enabled parameter from the GraphQLView and AsyncGraphQLView in Django and Channels integrations.

Chores:

  • Add a RELEASE.md file to document the changes in this release, indicating the removal of the subscriptions_enabled setting and the default enabling of WebSocket support.

Copy link
Contributor

sourcery-ai bot commented Oct 6, 2024

Reviewer's Guide by Sourcery

This pull request removes the subscriptions_enabled flag and related internal flags from various views and integrations. It simplifies the codebase by enabling WebSocket support by default in all GraphQL IDEs, addressing an outdated behavior that was originally implemented to fix a now-resolved issue in GraphiQL.

Updated class diagram for GraphQL views

classDiagram
    class BaseView {
        -_ide_replace_variables: bool
        -subscriptions_enabled: bool
        -_ide_subscription_enabled: bool
        +graphql_ide_html: str
        +allow_queries_via_get: bool
        +multipart_uploads_enabled: bool
    }
    class GraphQLView {
        -subscriptions_enabled: bool
        +graphiql: Optional[bool]
        +graphql_ide: Optional[GraphQL_IDE]
        +allow_queries_via_get: bool
    }
    class AsyncGraphQLView {
        -subscriptions_enabled: bool
        +graphiql: Optional[bool]
        +graphql_ide: Optional[GraphQL_IDE]
        +allow_queries_via_get: bool
    }
    class BaseGraphQLView {
        -_ide_subscription_enabled: bool
        +graphql_ide: Optional[GraphQL_IDE]
    }
    class GraphQLWebsocketCommunicator {
        -subscriptions_enabled: bool
        +allow_queries_via_get: bool
    }
    BaseView <|-- GraphQLView
    BaseView <|-- AsyncGraphQLView
    BaseView <|-- BaseGraphQLView
    BaseView <|-- GraphQLWebsocketCommunicator
Loading

File-Level Changes

Change Details Files
Removal of subscriptions_enabled flag and related internal flags
  • Removed subscriptions_enabled parameter from Django views
  • Removed _ide_replace_variables flag from BaseView
  • Removed _ide_subscription_enabled flag from various views
  • Removed logic for conditional subscription URL generation in GraphiQL template
strawberry/django/views.py
strawberry/http/base.py
strawberry/channels/handlers/http_handler.py
strawberry/quart/views.py
strawberry/chalice/views.py
strawberry/flask/views.py
strawberry/static/graphiql.html
Simplification of GraphQL IDE HTML generation
  • Removed subscription_enabled and replace_variables parameters from get_graphql_ide_html function
  • Simplified template rendering for GraphQL IDE
strawberry/http/ides.py
strawberry/django/views.py
Update to documentation
  • Removed references to subscriptions_enabled parameter in Django integration docs
  • Removed references to subscriptions_enabled parameter in Channels integration docs
  • Added RELEASE.md file explaining the changes
docs/integrations/django.md
docs/integrations/channels.md
RELEASE.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@DoctorJohn DoctorJohn changed the title Always enable subscriptions in ides Stop micromanaging WS support in IDEs Oct 6, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @DoctorJohn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@botberry
Copy link
Member

botberry commented Oct 6, 2024

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release removes the dated subscriptions_enabled setting from the Django and Channels integrations.
Instead, WebSocket support is now enabled by default in all GraphQL IDEs.

Here's the tweet text:

🆕 Release (next) is out! Thanks to @NucleonJohn for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

Copy link

codspeed-hq bot commented Oct 6, 2024

CodSpeed Performance Report

Merging #3660 will not alter performance

Comparing DoctorJohn:always-enable-subscriptions-in-ides (41095a3) with main (3484480)

Summary

✅ 15 untouched benchmarks

Copy link

codecov bot commented Oct 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.82%. Comparing base (34b40d4) to head (41095a3).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3660   +/-   ##
=======================================
  Coverage   96.82%   96.82%           
=======================================
  Files         503      503           
  Lines       33409    33392   -17     
  Branches     5583     5586    +3     
=======================================
- Hits        32348    32332   -16     
  Misses        830      830           
+ Partials      231      230    -1     

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@patrick91
Copy link
Member

@DoctorJohn feel free to merge when Pre commit is fine :D

@DoctorJohn DoctorJohn merged commit 1228f46 into strawberry-graphql:main Oct 7, 2024
117 checks passed
@DoctorJohn DoctorJohn deleted the always-enable-subscriptions-in-ides branch November 20, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Django AsyncGraphQLView param: subscriptions_enabled misleading
3 participants