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

refactor: graphiql template shared across servers #49

Merged

Conversation

KingDarBoja
Copy link
Contributor

@KingDarBoja KingDarBoja commented Jul 6, 2020

Fixes #48.

EDIT
I forgot to add the typing-extensions on the setup file in order to support the TypedDict 🤦‍♂️

@KingDarBoja KingDarBoja added the type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change label Jul 6, 2020
@KingDarBoja KingDarBoja requested review from Cito and jkimbo July 6, 2020 00:45
@KingDarBoja KingDarBoja self-assigned this Jul 6, 2020
variables: {{variables|tojson}},
operationName: {{operation_name|tojson}},
defaultQuery: {{default_query|tojson}},
headerEditorEnabled: {{header_editor_enabled|tojson}},
Copy link

Choose a reason for hiding this comment

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

might be worth adding shouldPersistHeaders as well, to decide whether or not the headers tab should persist it's values in localstorage by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you point out where it is defined? So far I am looking at the current renderGraphiQL.js implementation at the express-graphql package and I didn't saw shouldPersistHeaders.

Copy link

Choose a reason for hiding this comment

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

"graphiql_version": graphiql_version,
"graphiql_html_title": graphiql_html_title,
"query": data.get("query"),
"variables": data.get("variables"),
Copy link

Choose a reason for hiding this comment

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

we also have a new headers string prop that allows you to set the default headers value if you want :)

Copy link
Contributor Author

@KingDarBoja KingDarBoja Jul 6, 2020

Choose a reason for hiding this comment

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

I just noticed latest changes on renderGraphiQL.js have the headers option but it is passed at the graphQLFetcher function whereas these variables are passed to the ReactDom function.

Copy link

Choose a reason for hiding this comment

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

you can see the new props here: https://github.com/graphql/graphiql/tree/1.0.0/packages/graphiql#props

the headers that are passed in the fetcher function are the ones from the editor. the headers react prop is for pre-populating the headers editor

Comment on lines +36 to +43
<link href="//cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.css" rel="stylesheet" />
<script src="//cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/unfetch@4.1.0/dist/unfetch.umd.js"></script>
<script src="//cdn.jsdelivr.net/npm/react@16.13.1/umd/react.production.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/react-dom@16.13.1/umd/react-dom.production.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/graphiql@{{graphiql_version}}/graphiql.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/subscriptions-transport-ws@0.9.16/browser/client.js"></script>
<script src="//cdn.jsdelivr.net/npm/graphiql-subscriptions-fetcher@0.0.2/browser/client.js"></script>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on 1.0.0 readme, looks like the promise-polyfill cdn isn't needed, right? @acao

Also I noticed that the subscription-transport-ws package has been archived so I am not sure if there are alternatives up to date for supporting subscriptions. Do you have any idea about it?

Copy link

Choose a reason for hiding this comment

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

promise-polyfill has everything to do with whether you want IE support

subscription-transport-ws is still an active project and should be used. we removed it from our example and never got around to providing a new subscriptions example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I linked the wrong package, I meant graphiql-subscriptions-fetcher which still shows up on the use it with graphiql readme section of subscription-transport-ws.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, by looking at the subscription-transport-ws, I am a bit worried about the latest release as it was at March 2019 and there are several PRs and issues waiting for maintainers to be answered so not sure if it is active at another branch or fork but would be good to know.

Copy link
Member

@jkimbo jkimbo left a comment

Choose a reason for hiding this comment

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

Couple of small comments but otherwise this looks great!

graphql_server/aiohttp/graphqlview.py Outdated Show resolved Hide resolved
graphql_server/aiohttp/graphqlview.py Outdated Show resolved Hide resolved
Copy link
Member

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

@KingDarBoja KingDarBoja merged commit accfef4 into graphql-python:master Jul 11, 2020
@KingDarBoja KingDarBoja deleted the refactor-graphiql-template branch July 11, 2020 14:12
@KingDarBoja KingDarBoja added this to the GraphQL-Server (V3) milestone Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor graphiql template and update to latest version
3 participants