Skip to content
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

Merged
merged 25 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3c8299d
feat(gatsby): use graphiql-explorer
pieh May 23, 2019
08f6417
chore(docs): add some basic info to the README
DSchau May 23, 2019
ca9f47c
chore: format
pieh May 23, 2019
311485b
Update README.md
DSchau May 23, 2019
f2c10ac
Update packages/gatsby-graphiql-explorer/package.json
pieh May 23, 2019
3c02259
Update packages/gatsby-graphiql-explorer/src/app/webpack.config.js
pieh May 23, 2019
a8fc37f
show welcom to graphiql message with example tailored for gatsby users
pieh May 23, 2019
0cae8b2
store explorer pane state
pieh May 23, 2019
0e3cd30
actually commit the-thing
pieh May 23, 2019
ee4c119
add graphiql e2e tests
pieh May 24, 2019
866c30f
ooops :)
pieh May 24, 2019
7688af9
seems like sometimes there is timing issue when we execute query to f…
pieh May 24, 2019
b5c209b
tmp: record to personal cypress dashboard to investigate
pieh May 24, 2019
fa07a83
doh
pieh May 24, 2019
93f4f4d
use queryString instead of typing
pieh May 24, 2019
d57901f
doh again and again
pieh May 24, 2019
504eb84
revert tmp cypress dashboard integration
pieh May 24, 2019
cd709e8
Merge remote-tracking branch 'origin/master' into graphiql-explorer
pieh May 24, 2019
0069988
revert changes to package.json, fix double spaces
pieh May 24, 2019
44cbf89
Update packages/gatsby-graphiql-explorer/README.md
DSchau May 24, 2019
d6502e7
Update e2e-tests/development-runtime/cypress/integration/functionalit…
pieh May 24, 2019
67acb19
chore: fix issue
DSchau May 24, 2019
0556731
Merge branch 'graphiql-explorer' of github.com:gatsbyjs/gatsby into g…
DSchau May 24, 2019
ea49673
underscoregate
pieh May 24, 2019
b5229d1
you won the battle, not the war, mr underscore
pieh May 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
const endpoints = [`/___graphql`, `/_graphql`, `/___graphiql`]

const testQueryString = `?query=%7B%0A%20%20site%20%7B%0A%20%20%20%20siteMetadata%20%7B%0A%20%20%20%20%20%20title%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D`
pieh marked this conversation as resolved.
Show resolved Hide resolved

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`)
})
})
})
3 changes: 3 additions & 0 deletions packages/gatsby-graphiql-explorer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*.js
/*.html
yarn.lock
34 changes: 34 additions & 0 deletions packages/gatsby-graphiql-explorer/.npmignore
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
16 changes: 16 additions & 0 deletions packages/gatsby-graphiql-explorer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# gatsby-graphiql-explorer
Copy link
Contributor

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!


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`\_
DSchau marked this conversation as resolved.
Show resolved Hide resolved

![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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions packages/gatsby-graphiql-explorer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "gatsby-graphiql-explorer",
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 express.use(someMiddleware()), instead it is used as graphiqlExplorer(expressApp, params) as I need to have 2 route handlers (one for html and one for bundle)

Copy link
Contributor

Choose a reason for hiding this comment

The 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. @gatsbyjs/graphiql which is really what we've done here. We tweaked graphiql with some extra functionality.

"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"
}
}
19 changes: 19 additions & 0 deletions packages/gatsby-graphiql-explorer/src/app/app.css
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;
}
Loading