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

Extensions not shown in response #804

Closed
1 of 7 tasks
robrichard opened this issue Jul 31, 2018 · 2 comments
Closed
1 of 7 tasks

Extensions not shown in response #804

robrichard opened this issue Jul 31, 2018 · 2 comments

Comments

@robrichard
Copy link
Contributor

robrichard commented Jul 31, 2018

I found old issues (#651 & #303) that suggest this was fixed at some point, but it looks like it is broken again. With "tracing.hideTracingResponse" set to either true or false, all extensions are hidden from the results window in version 1.6.0

This issue pertains to the following package(s):

  • GraphQL Playground - Electron App
  • GraphQL Playground HTML
  • GraphQL Playground
  • GraphQL Playground Express Middleware
  • GraphQL Playground Lambda Middleware
  • GraphQL Playground Koa Middleware
  • GraphQL Playground Hapi Middleware

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

macOS 10.13.5

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?

Minimal example:


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`)
  })
})

@curry684
Copy link

curry684 commented Aug 9, 2018

I can confirm that in Apollo Server 2.0, which pulls in @apollographql/[email protected], the traces never appear no matter the setting of that config option.

@robrichard
Copy link
Contributor Author

I opened a PR to fix this: #813

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