Skip to content

Conversation

@boulc
Copy link
Contributor

@boulc boulc commented Nov 21, 2021

Context

The goal is to add support request headers in GraphiQL (discussed in #504).

Description

Request headers support has been added in recent versions of GraphiQL. Unfortunately, GraphiQL with extensions does not support it. As it wraps the GraphiQL component and masks the props, upgrading has no effect. There is not much activity on graphiql-with-extensions repo since some time now.

The current integration of GraphiQL has a broken support of subscription (see #544), due to the deprecation of subscribe function in apollographql/subscriptions-transport-ws#272. Also this dependency is still required though not maintained anymore until #492 is resolved. For the same reason, the current integration relies on graphiql-subscriptions-fetcher which is archived and not maintained anymore, also wrapping the GraphQLFetcher and masking the additional options necessary to support request headers.

Proposal

  1. Upgrading GraphiQL to version 1.5.1: cshtml file is inspired from CDN example.

  2. Adding an option to enable/disable GraphiQL with extensions: ExplorerExtensionEnabled, enabled by default for backward compatibility.

  3. Adding an option to enable/disable header editor: HeaderEditorEnabled, enable by default (same as in GraphiQL).

  4. Wrapping subscriptionsFetcher to pass additional option to support request headers editor.

  5. Downgrade subscriptions-transport-ws to version 0.8.2 to fix Subscriptions didnt work out of the box in current examples and readme.md #544.

Tests

Screenshot of side by side example of a mutation on the left leading to a working subscription on the right:

Screenshot 2021-11-20 210857

On the previous screenshot, the request headers editor is visible on the right and the authorization header is available in HTTP context when debugging:

Screenshot 2021-11-20 210339

@sungam3r sungam3r added enhancement New feature or request new API New non breaking public APIs added labels Nov 22, 2021
@sungam3r sungam3r added this to the v5.2 milestone Nov 23, 2021
@boulc boulc requested a review from sungam3r November 29, 2021 23:44
@sungam3r
Copy link
Member

sungam3r commented Dec 1, 2021

@boulc I remember about this PR. Too much work these days.

@Shane32 Shane32 mentioned this pull request Dec 29, 2021
3 tasks
@sungam3r
Copy link
Member

I need some time to check.

@sungam3r
Copy link
Member

@boulc Thanks for the fix. I don't know JS. I roughly understood what was happening here. I have two questions after which I will be glad to merge.

@Shane32
Copy link
Member

Shane32 commented Jan 1, 2022

@boulc @sungam3r Status? Waiting on this PR to release 5.2

@boulc
Copy link
Contributor Author

boulc commented Jan 1, 2022

I had some issues with missing SubscriptionDocumentExecuter while testing my latest changes so I had to add the dependency to GraphQL.SystemReactive to call AddSubscriptionDocumentExecuter extension (see 18cfa9d).
Also, I am suggesting another tweak to the sample, changing sentAt attribute from Date to DateTime nullable type and defaulting it to DateTime.UtcNow so it changes each time the mutation is executed: in the example below, the subscription reflects the mutation execution more accurately without having to change the mutation input to validate:

Animation

@Shane32
Copy link
Member

Shane32 commented Jan 1, 2022

Looks good. @sungam3r all set?

@sungam3r
Copy link
Member

sungam3r commented Jan 1, 2022

Wait a minute.

@sungam3r sungam3r merged commit d6b58a4 into graphql-dotnet:master Jan 1, 2022
@boulc boulc deleted the feat/graphiql-upgrade branch January 1, 2022 20:11
@boulc boulc restored the feat/graphiql-upgrade branch January 1, 2022 20:15
@boulc boulc deleted the feat/graphiql-upgrade branch January 1, 2022 20:15
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.27%. Comparing base (bed99b0) to head (001ffad).
⚠️ Report is 267 commits behind head on master.

Files with missing lines Patch % Lines
src/Ui.GraphiQL/Internal/GraphiQLPageModel.cs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #649      +/-   ##
==========================================
- Coverage   50.27%   50.27%   -0.01%     
==========================================
  Files          68       68              
  Lines        1838     1842       +4     
  Branches      184      185       +1     
==========================================
+ Hits          924      926       +2     
- Misses        860      862       +2     
  Partials       54       54              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request new API New non breaking public APIs added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subscriptions didnt work out of the box in current examples and readme.md

4 participants