Skip to content

Commit 7e886e8

Browse files
authored
Update GraphQL Playground to 1.7.28 version (#1190, #1069)
- track GraphQL Playground new versions via @dependabot - automate GraphQL Playground integration glue adapting for new versions
1 parent f9d9027 commit 7e886e8

File tree

10 files changed

+598
-561
lines changed

10 files changed

+598
-561
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ graphiql:
163163
make graphiql
164164

165165

166+
# Download and prepare actual version of GraphQL Playground static files, used
167+
# for integrating it.
168+
#
169+
# Usage:
170+
# make graphql-playground
171+
172+
graphql-playground:
173+
@cd juniper/ && \
174+
make graphql-playground
175+
176+
166177

167178

168179
##################
@@ -172,5 +183,5 @@ graphiql:
172183
.PHONY: book fmt lint release test \
173184
book.build book.serve \
174185
cargo.fmt cargo.lint cargo.release cargo.test \
175-
graphiql \
186+
graphiql graphql-playground \
176187
test.book test.cargo

juniper/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
7070

7171
- Made `GraphQLRequest` fields public. ([#750])
7272
- Relaxed [object safety] requirement for `GraphQLValue` and `GraphQLValueAsync` traits. ([ba1ed85b])
73+
- Updated [GraphQL Playground] to 1.7.28 version. ([#1190])
7374

7475
## Fixed
7576

@@ -123,6 +124,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
123124
[#1147]: /../../pull/1147
124125
[#1176]: /../../pull/1176
125126
[#1188]: /../../pull/1188
127+
[#1190]: /../../pull/1190
126128
[ba1ed85b]: /../../commit/ba1ed85b3c3dd77fbae7baf6bc4e693321a94083
127129
[CVE-2022-31173]: /../../security/advisories/GHSA-4rx6-g5vg-5f3j
128130

@@ -144,6 +146,7 @@ See [old CHANGELOG](/../../blob/juniper-v0.15.9/juniper/CHANGELOG.md).
144146
[Cargo feature]: https://doc.rust-lang.org/cargo/reference/features.html
145147
[`graphql-ws` GraphQL over WebSocket Protocol]: https://github.com/graphql/graphiql
146148
[GraphiQL]: https://github.com/enisdenjo/graphql-ws/master/PROTOCOL.md
149+
[GraphQL Playground]: https://github.com/prisma/graphql-playground
147150
[graphql-scalars.dev]: https://graphql-scalars.dev
148151
[October 2021]: https://spec.graphql.org/October2021
149152
[object safety]: https://doc.rust-lang.org/reference/items/traits.html#object-safety

juniper/Makefile

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ sed-i = sed -i$(if $(call eq,$(shell uname -s),Darwin), '',)
1818

1919
GRAPHIQL_VER ?= $(strip \
2020
$(shell grep -m1 '"graphiql": "' package.json | cut -d '"' -f4))
21+
GRAPHQL_PLAYGROUND_VER ?= $(strip \
22+
$(shell grep -m1 '"graphql-playground-react": "' package.json | cut -d '"' -f4))
2123

2224

2325

@@ -35,22 +37,37 @@ GRAPHIQL_VER ?= $(strip \
3537
graphiql:
3638
curl -fL -o src/http/graphiql.html \
3739
https://raw.githubusercontent.com/graphql/graphiql/graphiql%40$(GRAPHIQL_VER)/examples/graphiql-cdn/index.html
38-
$(sed-i) 's|https://unpkg.com/graphiql/|https://unpkg.com/graphiql@$(GRAPHIQL_VER)/|g' \
40+
$(sed-i) 's|unpkg.com/graphiql/|unpkg.com/graphiql@$(GRAPHIQL_VER)/|g' \
3941
src/http/graphiql.html
40-
$(sed-i) "s|'https://swapi-graphql.netlify.app/.netlify/functions/index'|GRAPHQL_URL|g" \
42+
$(sed-i) "s|'https://swapi-graphql.netlify.app/.netlify/functions/index'|JUNIPER_URL|g" \
4143
src/http/graphiql.html
42-
$(sed-i) "s|url: GRAPHQL_URL,|url: GRAPHQL_URL,\n subscriptionUrl: normalizeSubscriptionEndpoint(GRAPHQL_URL, GRAPHQL_SUBSCRIPTIONS_URL)|" \
44+
$(sed-i) "s|url: JUNIPER_URL,|url: JUNIPER_URL,\n subscriptionUrl: normalizeSubscriptionEndpoint(JUNIPER_URL, JUNIPER_SUBSCRIPTIONS_URL)|" \
4345
src/http/graphiql.html
4446
$(sed-i) 's|<script>|<script>\n<!-- inject -->|' \
4547
src/http/graphiql.html
4648
$(sed-i) '/X-Example-Header/d' \
4749
src/http/graphiql.html
4850

4951

52+
# Download and prepare actual version of GraphQL Playground static files, used
53+
# for integrating it.
54+
#
55+
# Usage:
56+
# make graphql-playground
57+
58+
graphql-playground:
59+
curl -fL -o src/http/playground.html \
60+
https://raw.githubusercontent.com/graphql/graphql-playground/graphql-playground-react%40$(GRAPHQL_PLAYGROUND_VER)/packages/graphql-playground-html/withAnimation.html
61+
$(sed-i) 's|cdn.jsdelivr.net/npm/graphql-playground-react/|cdn.jsdelivr.net/npm/graphql-playground-react@$(GRAPHQL_PLAYGROUND_VER)/|g' \
62+
src/http/playground.html
63+
$(sed-i) "s|// you can add more options here|endpoint: 'JUNIPER_URL', subscriptionEndpoint: 'JUNIPER_SUBSCRIPTIONS_URL'|" \
64+
src/http/playground.html
65+
66+
5067

5168

5269
##################
5370
# .PHONY section #
5471
##################
5572

56-
.PHONY: graphiql
73+
.PHONY: graphiql graphql-playground

juniper/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"private": true,
33
"scripts": {
4-
"postinstall": "make graphiql"
4+
"postinstall": "make graphiql graphql-playground"
55
},
66
"dependencies": {
7-
"graphiql": "3.0.5"
7+
"graphiql": "3.0.5",
8+
"graphql-playground-react": "1.7.28"
89
}
910
}

juniper/src/http/graphiql.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
<!-- inject -->
6060
const root = ReactDOM.createRoot(document.getElementById('graphiql'));
6161
const fetcher = GraphiQL.createFetcher({
62-
url: GRAPHQL_URL,
63-
subscriptionUrl: normalizeSubscriptionEndpoint(GRAPHQL_URL, GRAPHQL_SUBSCRIPTIONS_URL)
62+
url: JUNIPER_URL,
63+
subscriptionUrl: normalizeSubscriptionEndpoint(JUNIPER_URL, JUNIPER_SUBSCRIPTIONS_URL)
6464
});
6565
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
6666
root.render(

juniper/src/http/graphiql.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ pub fn graphiql_source(
2020

2121
include_str!("graphiql.html").replace(
2222
"<!-- inject -->",
23-
// Language: JavaScript
2423
&format!(
24+
// language=JavaScript
2525
"
26-
var GRAPHQL_URL = '{graphql_url}';
27-
var GRAPHQL_SUBSCRIPTIONS_URL = '{graphql_subscriptions_url}';
26+
var JUNIPER_URL = '{graphql_url}';
27+
var JUNIPER_SUBSCRIPTIONS_URL = '{graphql_subscriptions_url}';
2828
2929
{grahiql_js}
3030

0 commit comments

Comments
 (0)