Skip to content
Merged
Changes from all commits
Commits
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
15 changes: 13 additions & 2 deletions packages/gatsby/src/commands/data-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@
const express = require(`express`)
const graphqlHTTP = require(`express-graphql`)
const { store } = require(`../redux`)
const bootstrap = require(`../bootstrap`)
const { GraphQLSchema } = require(`graphql`)

// Note: the store must exist already. Create it with `gatsby build`.
module.exports = async (program: any) => {
let { port, host } = program
port = typeof port === `string` ? parseInt(port, 10) : port

// bootstrap to ensure schema is in the store
await bootstrap(program)

const schema = store.getState().schema

console.log(
`Schema is instance of GraphQLSchema?`,
schema instanceof GraphQLSchema
)

const app = express()
app.use(
`/`,
graphqlHTTP({
schema: store.getState().schema,
schema,
graphiql: true,
})
)
Expand Down