Skip to content

Commit 520ddea

Browse files
Fix graphiql explorer styles by including official CSS, and update local example app for testing (#1418)
* Add venv and .venv to gitignore since common venv paths * Update cookbook-plain app requirements and local-dev notes This also adds the DEFAULT_AUTO_FIELD to the app's Django settings to resolve this warning when running `migrate`: ``` ingredients.Category: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the IngredientsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. ``` * Fix #1417 graphiql explorer styles by including official CSS Like in the official graphiql-plugin-explorer example here https://github.com/graphql/graphiql/blob/619864691941c46cc0b0848e8713028e20212c36/packages/graphiql-plugin-explorer/examples/index.html#L26-L29 Resolves #1417 * Update GraphiQL version --------- Co-authored-by: Steven DeMartini <[email protected]> Co-authored-by: Kien Dang <[email protected]>
1 parent 38709d8 commit 520ddea

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ __pycache__/
1111
# Distribution / packaging
1212
.Python
1313
env/
14+
venv/
15+
.venv/
1416
build/
1517
develop-eggs/
1618
dist/

examples/cookbook-plain/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,12 @@ Now head on over to
6262
and run some queries!
6363
(See the [Graphene-Django Tutorial](http://docs.graphene-python.org/projects/django/en/latest/tutorial-plain/#testing-our-graphql-schema)
6464
for some example queries)
65+
66+
Testing local graphene-django changes
67+
-------------------------------------
68+
69+
In `requirements.txt`, replace the entire `graphene-django=...` line with the following (so that we install the local version instead of the one from PyPI):
70+
71+
```
72+
../../ # graphene-django
73+
```

examples/cookbook-plain/cookbook/settings.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
Generated by 'django-admin startproject' using Django 1.9.
66
77
For more information on this file, see
8-
https://docs.djangoproject.com/en/1.9/topics/settings/
8+
https://docs.djangoproject.com/en/3.2/topics/settings/
99
1010
For the full list of settings and their values, see
11-
https://docs.djangoproject.com/en/1.9/ref/settings/
11+
https://docs.djangoproject.com/en/3.2/ref/settings/
1212
"""
1313

1414
import os
@@ -18,7 +18,7 @@
1818

1919

2020
# Quick-start development settings - unsuitable for production
21-
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
21+
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
2222

2323
# SECURITY WARNING: keep the secret key used in production secret!
2424
SECRET_KEY = "_$=$%eqxk$8ss4n7mtgarw^5$8^d5+c83!vwatr@i_81myb=e4"
@@ -81,7 +81,7 @@
8181

8282

8383
# Database
84-
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
84+
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
8585

8686
DATABASES = {
8787
"default": {
@@ -90,9 +90,11 @@
9090
}
9191
}
9292

93+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
94+
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
9395

9496
# Password validation
95-
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
97+
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
9698

9799
AUTH_PASSWORD_VALIDATORS = [
98100
{
@@ -105,7 +107,7 @@
105107

106108

107109
# Internationalization
108-
# https://docs.djangoproject.com/en/1.9/topics/i18n/
110+
# https://docs.djangoproject.com/en/3.2/topics/i18n/
109111

110112
LANGUAGE_CODE = "en-us"
111113

@@ -119,6 +121,6 @@
119121

120122

121123
# Static files (CSS, JavaScript, Images)
122-
# https://docs.djangoproject.com/en/1.9/howto/static-files/
124+
# https://docs.djangoproject.com/en/3.2/howto/static-files/
123125

124126
STATIC_URL = "/static/"
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
graphene>=2.1,<3
2-
graphene-django>=2.1,<3
3-
graphql-core>=2.1,<3
4-
django==3.1.14
1+
django~=3.2
2+
graphene
3+
graphene-django>=3.1

graphene_django/templates/graphene/graphiql.html

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
integrity="{{graphiql_css_sri}}"
2222
rel="stylesheet"
2323
crossorigin="anonymous" />
24+
<link href="https://cdn.jsdelivr.net/npm/@graphiql/plugin-explorer@{{graphiql_plugin_explorer_version}}/dist/style.css"
25+
integrity="{{graphiql_plugin_explorer_css_sri}}"
26+
rel="stylesheet"
27+
crossorigin="anonymous" />
2428
<script src="https://cdn.jsdelivr.net/npm/whatwg-fetch@{{whatwg_fetch_version}}/dist/fetch.umd.js"
2529
integrity="{{whatwg_fetch_sri}}"
2630
crossorigin="anonymous"></script>

graphene_django/views.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,21 @@ class GraphQLView(View):
6666
react_dom_sri = "sha256-nbMykgB6tsOFJ7OdVmPpdqMFVk4ZsqWocT6issAPUF0="
6767

6868
# The GraphiQL React app.
69-
graphiql_version = "2.4.1" # "1.0.3"
70-
graphiql_sri = "sha256-s+f7CFAPSUIygFnRC2nfoiEKd3liCUy+snSdYFAoLUc=" # "sha256-VR4buIDY9ZXSyCNFHFNik6uSe0MhigCzgN4u7moCOTk="
71-
graphiql_css_sri = "sha256-88yn8FJMyGboGs4Bj+Pbb3kWOWXo7jmb+XCRHE+282k=" # "sha256-LwqxjyZgqXDYbpxQJ5zLQeNcf7WVNSJ+r8yp2rnWE/E="
69+
graphiql_version = "2.4.7"
70+
graphiql_sri = "sha256-n/LKaELupC1H/PU6joz+ybeRJHT2xCdekEt6OYMOOZU="
71+
graphiql_css_sri = "sha256-OsbM+LQHcnFHi0iH7AUKueZvDcEBoy/z4hJ7jx1cpsM="
7272

7373
# The websocket transport library for subscriptions.
74-
subscriptions_transport_ws_version = "5.12.1"
74+
subscriptions_transport_ws_version = "5.13.1"
7575
subscriptions_transport_ws_sri = (
7676
"sha256-EZhvg6ANJrBsgLvLAa0uuHNLepLJVCFYS+xlb5U/bqw="
7777
)
7878

7979
graphiql_plugin_explorer_version = "0.1.15"
8080
graphiql_plugin_explorer_sri = "sha256-3hUuhBXdXlfCj6RTeEkJFtEh/kUG+TCDASFpFPLrzvE="
81+
graphiql_plugin_explorer_css_sri = (
82+
"sha256-fA0LPUlukMNR6L4SPSeFqDTYav8QdWjQ2nr559Zln1U="
83+
)
8184

8285
schema = None
8386
graphiql = False

0 commit comments

Comments
 (0)