Host a GraphQL Server in Cloud Functions for Firebase with ES6+!
Here is the accompanying Medium Post.
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. Just use the most prominent, community drive implementation.
Host your GraphQL Server on Cloud Functions enabling rapid development with GraphQL on a low-cost, auto-scaling web server leveraging Firebase's sweet, sweet developer experience.
Cloud Functions can accept an Express Server object directly, so leverage the Apollo apollo-server-express pacakge to setup our GraphQL server.
The schema and resolvers are the same used in the Apollo example.
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>
git clone https://github.com/jthegedus/firebase-functions-graphql-example
cd firebase-functions-graphql-example
yarn install
yarn serve
This will serve the Cloud Functions locally using the Firebase emulator.
yarn deploy
N.B.: Replace <project-name>
in the .firebaserc
to connect the project to your Firebase project.
Everything was tested on Ubuntu 16.04 & Windows 10 with Bash on Ubuntu on Windows. If you wish for Windows native support please submit an issue so we can work on a Windows branch. Please report any macOS errors as I do not have access to a device to test. My development environment can be found here.