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

Upgrade GraphiQL to 1.5.1 #649

Merged
merged 21 commits into from
Jan 1, 2022

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.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Shane32 Shane32 mentioned this pull request Dec 29, 2021
3 tasks
boulc and others added 2 commits December 29, 2021 03:02

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
boulc and others added 4 commits December 29, 2021 14:49

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
@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?

@codecov-commenter
Copy link

Codecov Report

Merging #649 (001ffad) into master (bed99b0) will decrease coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
src/Ui.GraphiQL/Internal/GraphiQLPageModel.cs 0.00% <0.00%> (ø)
src/Ui.GraphiQL/GraphiQLOptions.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bed99b0...001ffad. Read the comment docs.

@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
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