Host a GraphQL Server on Google Cloud Functions by routing requests through the apollo-sever-express package.
This method is markedly simpler than any other GraphQL-on-FaaS method I have seen. No custom packages for GCP or struggling with API Gateway or complex setup instructions for AWS.
Babel is used to compile to the target runtime, for more information on this setup read Babel & preset-env & ES6+ in Cloud Functions for Firebase #2
Endpoint | Route |
---|---|
Schema | https://us-central1-<project-name>.cloudfunctions.net/api/schema |
GraphiQL | https://us-central1-<project-name>.cloudfunctions.net/api/graphiql |
GraphQL | https://us-central1-<project-name>.cloudfunctions.net/api/graphql?<query> |
- Install the "Cloud SDK" (gcp cli tool) following your systems instrucitons - https://cloud.google.com/sdk/downloads
- Initialize the Cloud SDK - https://cloud.google.com/sdk/docs/initializing
gcloud init
You should be prompt by the Cloud SDK to select your GCP project at this step.
## Deploy to Google Cloud Functions
```shell
yarn deploy