-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): use graphiql-explorer #14280
Changes from all commits
3c8299d
08f6417
ca9f47c
311485b
f2c10ac
3c02259
a8fc37f
0cae8b2
0e3cd30
ee4c119
866c30f
7688af9
b5c209b
fa07a83
93f4f4d
d57901f
504eb84
cd709e8
0069988
44cbf89
d6502e7
67acb19
0556731
ea49673
b5229d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
const endpoints = [`/___graphql`, `/_graphql`, `/___graphiql`] | ||
|
||
const testQueryString = `?query=${encodeURIComponent(`{ | ||
site { | ||
siteMetadata { | ||
title | ||
} | ||
} | ||
}`)}` | ||
|
||
describe(`The GraphQL endpoint`, () => { | ||
endpoints.forEach(endpoint => { | ||
it(`Should appear on ${endpoint}`, () => { | ||
cy.visit(endpoint) | ||
cy.title().should(`eq`, `GraphiQL`) | ||
}) | ||
|
||
it(`Should execute queries from query string on ${endpoint}`, () => { | ||
// prefill query from query string | ||
cy.visit(endpoint + testQueryString) | ||
cy.get(`.execute-button`).click() | ||
cy.get(`.result-window .CodeMirror-code`).contains( | ||
`Gatsby Default Starter` | ||
) | ||
}) | ||
|
||
it(`Should execute queries created with explorer on ${endpoint}`, () => { | ||
// hack to show (almost) empty editor instead of | ||
cy.visit(endpoint + `?query=%20`) | ||
cy.get(`[data-field-name="site"]`).click() | ||
cy.get(`[data-field-name="port"]`).click() | ||
cy.get(`.execute-button`).click() | ||
cy.get(`.result-window .CodeMirror-code`).contains(`8000`) | ||
}) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*.js | ||
/*.html | ||
yarn.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
*.un~ | ||
yarn.lock | ||
src | ||
flow-typed | ||
coverage | ||
decls | ||
examples |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# gatsby-graphiql-explorer | ||
|
||
A package to extend the default [GraphiQL][graphiql] IDE with useful features for Gatsby users. | ||
|
||
_Note:_ accessible at http://localhost:8000/___graphql after running `gatsby develop` | ||
|
||
![Gatsby GraphiQL Explorer](./assets/gatsby-graphiql-explorer.png) | ||
|
||
## Features | ||
|
||
- Offline support - for when you need to work on your excellent Gatsby app on a plane, train, or elsewhere off the grid | ||
- [GraphiQL Explorer][graphiql-explorer] - an interactive explorer plugin to visually create and interact with the GraphQL schema | ||
- _All_ the expected features you know and love from [GraphiQL][graphiql] | ||
|
||
[graphiql]: https://github.com/graphql/graphiql | ||
[graphiql-explorer]: https://github.com/OneGraph/graphiql-explorer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "gatsby-graphiql-explorer", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this probably need better package name - this is kind of express middleware, but not exactly, because it's not used as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's easy to bike shed here--I don't really have a problem with the name. We could also scope it, e.g. |
||
"version": "0.0.1", | ||
"description": "GraphiQL IDE with custom features for Gatsby users", | ||
"main": "index.js", | ||
"scripts": { | ||
"build:app": "webpack --config ./src/app/webpack.config.js", | ||
"build:babel": "babel src/index.js --out-dir . --ignore **/__tests__", | ||
"build": "npm-run-all --parallel build:app build:babel", | ||
"prepare": "cross-env NODE_ENV=production npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"watch:app": "npm run build:app -- --watch", | ||
"watch:babel": "npm run build:babel -- --watch", | ||
"watch": "npm-run-all --parallel watch:app watch:babel" | ||
}, | ||
"keywords": [ | ||
"gatsby" | ||
], | ||
"author": "", | ||
"bugs": { | ||
"url": "https://github.com/gatsbyjs/gatsby/issues" | ||
}, | ||
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-graphiql-explorer#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/gatsbyjs/gatsby.git" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"graphiql": "^0.13.0", | ||
"graphiql-explorer": "^0.3.7", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"whatwg-fetch": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0", | ||
"@babel/plugin-transform-runtime": "^7.0.0", | ||
"@babel/preset-env": "^7.4.1", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-loader": "^8.0.0", | ||
"babel-preset-gatsby-package": "^0.1.4", | ||
"cross-env": "^5.0.5", | ||
"css-loader": "^1.0.0", | ||
"html-webpack-plugin": "^3.2.0", | ||
"npm-run-all": "4.1.5", | ||
"style-loader": "^0.21.0", | ||
"webpack-cli": "^3.3.2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
monospace; | ||
} | ||
|
||
.graphiql-container { | ||
height: 100vh; | ||
width: 100vw; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and concise 🤷♂ I think this will suffice!