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

Document how to render a custom graphql IDE #3664

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented Oct 7, 2024

Description

This PR adds integration-specific guides on rendering a custom GraphQL IDE in case our graphql_ide option is too basic.

(This PR also fixes one related type in the ASGI view that was too broad.)

Types of Changes

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

Issues Fixed or Closed by This PR

Summary by Sourcery

Enhance the GraphQL integration by allowing customization of the GraphQL IDE rendering and update the documentation to guide users on implementing this feature across multiple frameworks.

Enhancements:

  • Add the ability to override the render_graphql_ide method for more control over the rendering of the GraphQL IDE across various integrations.

Documentation:

  • Provide detailed documentation on how to extend the GraphQL view or controller to render a custom GraphQL IDE for different frameworks including Django, Flask, Quart, Sanic, Aiohttp, ASGI, Chalice, and FastAPI.

Copy link
Contributor

sourcery-ai bot commented Oct 7, 2024

Reviewer's Guide by Sourcery

This pull request adds documentation on how to render a custom GraphQL IDE across various integrations. It introduces a new render_graphql_ide method that can be overridden to provide custom IDE rendering functionality. The changes are primarily focused on enhancing documentation and providing more flexibility for users who need more control over the GraphQL IDE rendering process.

Class diagram for the new render_graphql_ide method

classDiagram
    class GraphQLView {
        +HttpResponse render_graphql_ide(HttpRequest request)
    }
    class AsyncGraphQLView {
        +HttpResponse render_graphql_ide(HttpRequest request)
    }
    class GraphQLController {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLView {
        +HttpResponse render_graphql_ide(HttpRequest request)
    }
    class MyGraphQLController {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLHTTPConsumer {
        +ChannelsResponse render_graphql_ide(ChannelsRequest request)
    }
    class MyGraphQLRouter {
        +HTMLResponse render_graphql_ide(Request request)
    }
    class MyGraphQL {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLView~Flask~ {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLView~Sanic~ {
        +HTTPResponse render_graphql_ide(Request request)
    }
    class MyGraphQLView~Aiohttp~ {
        +web.Response render_graphql_ide(web.Request request)
    }
    class MyGraphQLView~Chalice~ {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLView~Quart~ {
        +Response render_graphql_ide(Request request)
    }
    class MyGraphQLView~Django~ {
        +HttpResponse render_graphql_ide(HttpRequest request)
    }
Loading

File-Level Changes

Change Details Files
Added documentation for rendering custom GraphQL IDE
  • Introduced new render_graphql_ide method in various integration classes
  • Provided example code for overriding render_graphql_ide method
  • Updated method signatures to include render_graphql_ide
  • Added explanations on when and how to use custom IDE rendering
docs/integrations/django.md
docs/integrations/litestar.md
docs/integrations/flask.md
docs/integrations/quart.md
docs/integrations/channels.md
docs/integrations/sanic.md
docs/integrations/aiohttp.md
docs/integrations/asgi.md
docs/integrations/chalice.md
docs/integrations/fastapi.md
Minor code improvements and formatting changes
  • Updated method signatures for clarity
  • Fixed typos and improved formatting in documentation
  • Adjusted indentation and spacing for better readability
strawberry/asgi/__init__.py

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

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: 1 issue found

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.

async def render_graphql_ide(self, request: Request) -> Response:
custom_html = """<html><body><h1>Custom GraphQL IDE</h1></body></html>"""

return Response(self.graphql_ide_html)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (documentation): Incorrect variable used in Quart integration example

The example uses self.graphql_ide_html instead of the custom_html variable defined earlier in the function.

@botberry
Copy link
Member

botberry commented Oct 7, 2024

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

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

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.93%. Comparing base (7feeea9) to head (05c9d62).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3664      +/-   ##
==========================================
+ Coverage   96.66%   96.93%   +0.26%     
==========================================
  Files         504      504              
  Lines       33448    33448              
  Branches     5600     5600              
==========================================
+ Hits        32333    32423      +90     
+ Misses        881      793      -88     
+ Partials      234      232       -2     

Copy link

codspeed-hq bot commented Oct 7, 2024

CodSpeed Performance Report

Merging #3664 will not alter performance

Comparing DoctorJohn:document-how-to-self-host-a-graphql-ide (05c9d62) with main (7feeea9)

Summary

✅ 15 untouched benchmarks

@patrick91 patrick91 merged commit 0bc9773 into strawberry-graphql:main Oct 7, 2024
116 of 117 checks passed
@DoctorJohn DoctorJohn deleted the document-how-to-self-host-a-graphql-ide branch November 20, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graphql_ide self hosting
3 participants