@@ -18,6 +18,8 @@ sed-i = sed -i$(if $(call eq,$(shell uname -s),Darwin), '',)
1818
1919GRAPHIQL_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 \
3537graphiql :
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
0 commit comments