question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support a different URL for playground

See original GitHub issue
  • feature

I know I can provide parameter path when calling server.applyMiddleware({ app, path });. But it looks like this path will be used for both the GraphQL API endpoint (when using XHR) and also for the playground (when visiting in a browser). Is it possible to use different URLs for them? e.g. /api/graphql for the endpoint and /graphql-playground for the playground

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:25 (7 by maintainers)

github_iconTop GitHub Comments

10reactions
mondaychencommented, Nov 1, 2018

I found https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-express/src/ApolloServer.ts

It does not look like it’s supported.

If this sounds like a valid feature request, I can work on this and submit a merge request next week.

9reactions
Pocket-titancommented, May 2, 2019

If I’m not mistaken, the playground key accepts an endpoint parameter like so:

import { ApolloServer } from 'apollo-server'

const server = new ApolloServer({
    playground: {
        endpoint: 'http://localhost:4000/graphql', // I think this is the default one
    },
})

So in your case, I believe you could do this (using express here as an example)

import express from 'express'
import { ApolloServer } from 'apollo-server-express'

const app = express()

const server = new ApolloServer({
    playground: {
        endpoint: `http://${your_domain_here}:${your_port_here}/graphql-playground`,
    },
})

server.applyMiddleware({
    app,
    path: '/api/graphql',
})

app.listen(your_port_here, () => {
    console.log(`Serving graphql api on /api/graphql and playground on /graphql-playground!`)
})

where you’d replace your_domain_here and your_port_here with your own variables, naturally. The shape of endpoint can be found here: https://github.com/prisma/graphql-playground#properties.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL Playground - Apollo GraphQL Docs
In development, Apollo Server enables GraphQL Playground on the same URL as the GraphQL server itself (e.g. http://localhost:4000/graphql ) and automatically ...
Read more >
Configuring Apollo Playground and API on two different URL
The website and the API are both using the same URL. It is problematic if you want the playground to use a particular...
Read more >
How to change websocket url in graphql-playground ...
I wanted to change the graphql websocket end point inside graphql, anyone know how to do this? by default it pings wss://localhost/graphql. I ......
Read more >
trailhead playground url issue - Salesforce Developers
1. Scroll to the bottom of this page. · 2. Click the arrow next to Launch and select Create a Trailhead Playground. Don't...
Read more >
Complete guide to GraphQL Playground - LogRocket Blog
It's built on top of GraphiQL with additional features such as automatic schema reloading, support for GraphQL subscriptions, the ability to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found