-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- track GraphiQL new version via @dependabot - automate GraphiQL integration glue adapting for new versions - rework `example/warp_subscriptions` to support subscriptions in new GraphiQL
- Loading branch information
Showing
14 changed files
with
259 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/package-lock.json | ||
/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
############################### | ||
# Common defaults/definitions # | ||
############################### | ||
|
||
# Checks two given strings for equality. | ||
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ | ||
$(findstring $(2),$(1))),1) | ||
|
||
# Multiplatform prefix of `sed -i` commands. | ||
sed-i = sed -i$(if $(call eq,$(shell uname -s),Darwin), '',) | ||
|
||
|
||
|
||
|
||
###################### | ||
# Project parameters # | ||
###################### | ||
|
||
GRAPHIQL_VER ?= $(strip \ | ||
$(shell grep -m1 '"graphiql": "' package.json | cut -d '"' -f4)) | ||
|
||
|
||
|
||
|
||
############ | ||
# Commands # | ||
############ | ||
|
||
# Download and prepare actual version of GraphiQL static files, used for | ||
# integrating it. | ||
# | ||
# Usage: | ||
# make graphiql | ||
|
||
graphiql: | ||
curl -fL -o src/http/graphiql.html \ | ||
https://raw.githubusercontent.com/graphql/graphiql/graphiql%40$(GRAPHIQL_VER)/examples/graphiql-cdn/index.html | ||
$(sed-i) 's|https://unpkg.com/graphiql/|https://unpkg.com/graphiql@$(GRAPHIQL_VER)/|g' \ | ||
src/http/graphiql.html | ||
$(sed-i) "s|'https://swapi-graphql.netlify.app/.netlify/functions/index'|GRAPHQL_URL|g" \ | ||
src/http/graphiql.html | ||
$(sed-i) "s|url: GRAPHQL_URL,|url: GRAPHQL_URL,\n subscriptionUrl: normalizeSubscriptionEndpoint(GRAPHQL_URL, GRAPHQL_SUBSCRIPTIONS_URL)|" \ | ||
src/http/graphiql.html | ||
$(sed-i) 's|<script>|<script>\n<!-- inject -->|' \ | ||
src/http/graphiql.html | ||
$(sed-i) '/X-Example-Header/d' \ | ||
src/http/graphiql.html | ||
|
||
|
||
|
||
|
||
################## | ||
# .PHONY section # | ||
################## | ||
|
||
.PHONY: graphiql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"postinstall": "make graphiql" | ||
}, | ||
"dependencies": { | ||
"graphiql": "3.0.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!-- | ||
* Copyright (c) 2021 GraphQL Contributors | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
--> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>GraphiQL</title> | ||
<style> | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
width: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
#graphiql { | ||
height: 100vh; | ||
} | ||
</style> | ||
|
||
<!-- | ||
This GraphiQL example depends on Promise and fetch, which are available in | ||
modern browsers, but can be "polyfilled" for older browsers. | ||
GraphiQL itself depends on React DOM. | ||
If you do not want to rely on a CDN, you can host these files locally or | ||
include them directly in your favored resource bundler. | ||
--> | ||
<script | ||
crossorigin | ||
src="https://unpkg.com/react@18/umd/react.development.js" | ||
></script> | ||
<script | ||
crossorigin | ||
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" | ||
></script> | ||
<script | ||
src="https://unpkg.com/graphiql@3.0.5/graphiql.min.js" | ||
type="application/javascript" | ||
></script> | ||
<script | ||
src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js" | ||
crossorigin | ||
></script> | ||
<!-- | ||
These two files can be found in the npm module, however you may wish to | ||
copy them directly into your environment, or perhaps include them in your | ||
favored resource bundler. | ||
--> | ||
<link rel="stylesheet" href="https://unpkg.com/graphiql@3.0.5/graphiql.min.css" /> | ||
</head> | ||
|
||
<body> | ||
<div id="graphiql">Loading...</div> | ||
<script> | ||
<!-- inject --> | ||
const root = ReactDOM.createRoot(document.getElementById('graphiql')); | ||
const fetcher = GraphiQL.createFetcher({ | ||
url: GRAPHQL_URL, | ||
subscriptionUrl: normalizeSubscriptionEndpoint(GRAPHQL_URL, GRAPHQL_SUBSCRIPTIONS_URL) | ||
}); | ||
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin(); | ||
root.render( | ||
React.createElement(GraphiQL, { | ||
fetcher, | ||
defaultEditorToolsVisibility: true, | ||
plugins: [explorerPlugin], | ||
}), | ||
); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function normalizeSubscriptionEndpoint(endpoint, subscriptionEndpoint) { | ||
if (subscriptionEndpoint) { | ||
if (subscriptionEndpoint.startsWith('/')) { | ||
const secure = | ||
endpoint.includes('https') || location.href.includes('https') | ||
? 's' | ||
: '' | ||
return `ws${secure}://${location.host}${subscriptionEndpoint}` | ||
} else { | ||
return subscriptionEndpoint.replace(/^http/, 'ws') | ||
} | ||
} | ||
return null | ||
} |
Oops, something went wrong.