Running GraphQL server on Google Cloud App Engine

2k Views Asked by At

In node.js to run the endpoint locally, I use the following snippet in my app.js

app.use('/graphql', (0, _expressGraphql2.default)(function (req) {
  return {
    schema: _schema2.default,
    pretty: true,
    context: _extends({ db: _models2.default }, (0, _isUser2.default)(req.headers['authorization'].split(' ')[1]))
  };
}));
app.listen(8080, function () {

However, my app isn't receiving any response from the endpoint on trying to reach hostname:8080/graphql. This works on my local machine.

1

There are 1 best solutions below

3
On

The title of your post indicates that your node.js app is deployed in Google App Engine. There is no need to worry about assigning an IP address to your instance in that environment. Instances are managed by the App Engine, and so is the routing of requests to your application.

To access the app, once deployed to the App Engine, one only needs to address it following the pattern: app_name.appspot.com. Alternatively, for a custom domain, you can follow the “Using Custom Domains and SSL” guide [1]. Sub-chapter “Adding SSL to your custom domain” of this document may help you with the setting up of SSL, if needed.

The app listens on port 8080 by default in the app engine. This is of no concern to an outside caller, who can only use the following the pattern: app_name.appspot.com to call the app. This situation is valid for the app engine environment.

[1] https://cloud.google.com/appengine/docs/flexible/nodejs/using-custom-domains-and-ssl