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

Update GraphiQL page to the latest version #1889

Merged
merged 14 commits into from
Aug 29, 2022

Conversation

MattExact
Copy link
Contributor

Description

Updated the GraphiQL page to use [email protected] (was previously using [email protected]).

This is necessary because older versions of GraphiQL have a Cross-site Scripting vulnerability (see snyk and the GraphiQL docs).

I have updated the file to be based upon the CDN example provided by the GraphiQL team.

I have made a couple of modifications to the file to bring in line with our current GraphiQL page:

  • Using the GraphiQL provided fetcher with the subscriptions URL (dependent on if subscriptions are enabled for the integration)
  • Added a CSRF token, which was a previous modification to the file made in this PR

There are a couple of changes to the interface due to the updated version, most notably the loss of the "Explorer".
It may be possible to add this back in via the graphiql-explorer package.

Types of Changes

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

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@codecov
Copy link

codecov bot commented May 8, 2022

Codecov Report

Merging #1889 (1565e78) into main (3201e3f) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1889      +/-   ##
==========================================
- Coverage   98.20%   98.19%   -0.01%     
==========================================
  Files         161      160       -1     
  Lines        6405     6379      -26     
  Branches     1205     1203       -2     
==========================================
- Hits         6290     6264      -26     
  Misses         58       58              
  Partials       57       57              

@botberry
Copy link
Member

botberry commented May 8, 2022

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release updates the built-in GraphiQL version to version 2.0,
which means you can now enjoy all the new features that come with the latest version!


Here's the preview release card for twitter:

Here's the tweet text:

🆕 Release (next) is out! We updated @GraphiQL to version 2.0!

Thanks to Matt for creating the original, @patrick91 for taking over and the whole @GraphiQL
team for releasing the new version of GraphiQL! ❤️

Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)

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.

looks good, I've only added a comment about the favicon.

Would be willing to spend a bit of time trying to add the explorer again? I think it is pretty useful :)

strawberry/static/graphiql.html Outdated Show resolved Hide resolved
@MattExact
Copy link
Contributor Author

I have now added in the GraphiQL Explorer using OneGraph's package (see here for repo and here for the example I based it off)

I'm ngl doing it with CDN based packages provided some limitations and challenges but I think I got it working pretty well 😅

See below for how it looks
image
The styles aren't super clean, but this is actually the case for OneGraph's own implementation strangely enough https://www.onegraph.com/graphiql

PS: I seem to have broken Windows builds somehow with my file encoding 🙈

@MattExact MattExact requested a review from patrick91 May 13, 2022 22:37
RELEASE.md Outdated Show resolved Hide resolved
@patrick91 patrick91 force-pushed the update-graphiql-page branch from 889dd9e to c438944 Compare May 20, 2022 04:07
@patrick91
Copy link
Member

@MattExact this seems to be slightly broken for me:

image

it doesn't get the field for the people field, is this something you can reproduce as well?

@patrick91
Copy link
Member

@MattExact there's version 2 of GraphiQL coming out soon, maybe we can wait for that, I tried a pre-release on this PR and it seems to work:

image

it doesn't have the same explorer capabilities yet, but it is planned, there's even a prototype here: https://jonathanawesome.github.io/graphiql-v2-prototype/?mode=preview&story=reference--reference

@MattExact
Copy link
Contributor Author

@patrick91 Apologies I forgot to reply to your previous comment, I was able to replicate your problem.
However, I was unable to figure out a way to fix it, my guess is it's probably fixed by the parts of the GraphiQL explorer example that I was unable to replicate using CDN packages.

I would be inclined to wait for v2, and hopefully they have decent support for using GraphiQL with a CDN 🤞

@patrick91
Copy link
Member

No worries! I'll update this PR with the beta so we have it ready for the release 😌

@ryou90
Copy link

ryou90 commented Jul 28, 2022

Any news on this?

@patrick91
Copy link
Member

we are still waiting for the release of GraphiQL v2 😊

@ryou90
Copy link

ryou90 commented Jul 28, 2022

Is it not possible to use a preview version? It seems like it will be a while before there is a release or beta.

@patrick91
Copy link
Member

Is it not possible to use a preview version? It seems like it will be a while before there is a release or beta.

I think the release should happen soon, see: https://discord.com/channels/625400653321076807/966768858402816020/1001946875093602476

CleanShot 2022-07-28 at 13 08 00@2x

I'd prefer to release an update with a stable version of GraphiQL 😊

@patrick91
Copy link
Member

patrick91 commented Aug 25, 2022

GraphiQL 2 has been released! I'll see if I can update this PR this week :) I need to figure out how to get the explorer working via the CDN version of GraphiQL.

Ref: https://github.com/graphql/graphiql/blob/main/examples/graphiql-explorer/src/App.tsx

@patrick91
Copy link
Member

I think we'll be able to update when this PR is released 😊 graphql/graphiql#2699

@patrick91
Copy link
Member

seems there's a couple of small issues, as soon as they are fixed I'll merge this PR 😊

@patrick91
Copy link
Member

also I need to reintroduce support for websockets 😊

@patrick91 patrick91 force-pushed the update-graphiql-page branch from 8fe81b1 to 6f8bc3a Compare August 25, 2022 15:22
@patrick91
Copy link
Member

/pre-release

@botberry
Copy link
Member

Pre-release

👋

Releasing commit [a43d9bf] to PyPi as pre-release! 📦

@botberry
Copy link
Member

Pre-release

👋

Pre-release 0.127.0.dev.1661797666 [a43d9bf] has been released on PyPi! 🚀
You can try it by doing:

poetry add strawberry-graphql==0.127.0.dev.1661797666

@patrick91 patrick91 force-pushed the update-graphiql-page branch from cb08ead to 1565e78 Compare August 29, 2022 19:55
@patrick91 patrick91 enabled auto-merge (squash) August 29, 2022 20:02
@patrick91 patrick91 disabled auto-merge August 29, 2022 20:02
@patrick91 patrick91 merged commit a19abda into strawberry-graphql:main Aug 29, 2022
@star2000
Copy link
Member

The following CSS needs to be added to make the explorer scrollable and fully display the "Add new" below.

.doc-explorer-contents {
  overflow-y: hidden !important;
}

.docExplorerWrap {
  width: unset !important;
  min-width: unset !important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Update graphiql version
5 participants