Home Resolution of 'Unable to reach server' issue in GraphQL Studio due to local server connection
Post
Cancel

Resolution of 'Unable to reach server' issue in GraphQL Studio due to local server connection

Problem Situation

Problem

I encountered an issue while setting up a GraphQL environment where GraphQL Studio kept redirecting to an external server. It consistently redirected to https://studio.apollographql.com/, and since the GraphQL server I configured exists within an internal development network, it couldn’t receive requests from an external server. I wanted to test it locally without redirection.

Solution

I added additional code as mentioned in the document How to Use Apollo Sandbox on Your Localhost.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const {
 ApolloServerPluginLandingPageProductionDefault,
 ApolloServerPluginLandingPageLocalDefault
} = require('apollo-server-core');

const server = new ApolloServer({
 ...
 plugins: [
    process.env.NODE_ENV === "production"
      ? ApolloServerPluginLandingPageProductionDefault({
          embed: true,
          graphRef: "plaid-gufzoj@current"
        })
      : ApolloServerPluginLandingPageLocalDefault({ embed: true })
 ]
});

Resolved Situation

Solved

Now, as shown above, you can see the GraphQL Studio UI for local testing without redirection.

This post is licensed under CC BY 4.0 by the author.