fix(router): Render GraphiQL when accepting text/html with highest q-weight#705
fix(router): Render GraphiQL when accepting text/html with highest q-weight#705
Conversation
Summary of ChangesHello @enisdenjo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request streamlines the process of serving the GraphiQL interface by integrating its detection directly into the HTTP content negotiation pipeline. It introduces a specific Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the content negotiation logic to correctly serve the GraphiQL interface based on the Accept header's q-weights. The changes are well-structured, introducing a ResponseMode::GraphiQL variant and using the headers-accept crate for proper negotiation, which is a significant improvement over the previous string-based check. The logic is now more robust and correct. The tests have also been updated effectively to cover the new behavior, including cases for different HTTP methods.
I have one minor suggestion regarding a piece of dead code that results from an inconsistency between a trait's method signature and its implementation, which could be cleaned up to improve maintainability.
✅
|
|
🐋 This PR was built and pushed to the following Docker images: Image Names: Platforms: Image Tags: Docker metadata{
"buildx.build.ref": "builder-12ba1cd7-afc9-4e49-860b-7c83ed354e5a/builder-12ba1cd7-afc9-4e49-860b-7c83ed354e5a0/7alv67vvto2xydiu995tejf1s",
"containerimage.descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:9d042eee88ccdd811db4d1d1a438d0ce3ad2d5ec450afecee07481726b511224",
"size": 1609
},
"containerimage.digest": "sha256:9d042eee88ccdd811db4d1d1a438d0ce3ad2d5ec450afecee07481726b511224",
"image.name": "ghcr.io/graphql-hive/router:pr-705,ghcr.io/graphql-hive/router:sha-decd0a4"
} |
Closes #704
Now the
ResponseModeintroduced at #665 will also consider theGraphiQLresponse mode and negotiate accordingly with browsers that accept both JSON and HTML, but prefer HTML as per the q-weight.