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

Playground filtering response (extensions being hidden) #651

Closed
1 task done
jedahan opened this issue Apr 18, 2018 · 1 comment
Closed
1 task done

Playground filtering response (extensions being hidden) #651

jedahan opened this issue Apr 18, 2018 · 1 comment

Comments

@jedahan
Copy link

jedahan commented Apr 18, 2018

playground_filtering

This issue pertains to the following package(s):

  • GraphQL Playground HTML

What OS and OS version are you experiencing the issue(s) on?

macOS 10.13.4

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?

graphql-playground-middleware-koa

What is the expected behavior?

I see the complete response in the result window

What is the actual behavior?

The result window response does not match the network response, specifically, it swallows the extensions: { duration } object.

What steps may we take to reproduce the behavior?

https://github.com/jedahan/playground-filtering has a relatively minimal example, which I will copy below

# server.js

const Koa = require('koa')
const mount = require('koa-mount')
const cors = require('@koa/cors')
const graphqlHTTP = require('koa-graphql')
const koaPlayground = require('graphql-playground-middleware-koa').default
const opn = require('opn')
const getPort = require('get-port')
const app = new Koa()

const { buildSchema } = require('graphql')
const schema = buildSchema(`
type Query {
  hello: Hello,
}
type Hello {
  there: String
}
type Mutation {
  setHello(input: HelloInput!): Hello
}
input HelloInput {
  there: String!
}
`)

const db = {
  hello: {
    there: `General Kenobi!`
  }
}

const rootValue = {
  hello: () => db.hello,
  setHello: ({ hello }) => {
    previous = db.hello
    db.hello = hello
    return previous
  }
}

app.use(cors())

app.use(
  mount(
    '/graphql',
    graphqlHTTP(async (request) => {
      const start = Date.now()
      const extensions = ({ document, variables, operationName, result }) => ({
        duration: new Date() - start
      })
      return { schema, rootValue, extensions }
    })
  )
)

app.use(
  mount(
    '/playground',
    koaPlayground({
      endpoint: '/graphql'
    })
  )
)

getPort({ port: 4000 }).then(port => {
  app.listen(port, () => {
    const base = `http://localhost:${port}`
    console.log(`API: ${base}/graphql`)
    console.log(`Playground: ${base}/playground`)
    opn(`${base}/playground`)
  })
})
@timsuchanek
Copy link
Member

Thanks for reporting @jedahan !
This is already possible, I just added it to the readme: https://github.com/prismagraphql/graphql-playground/blob/master/README.md#settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants