jthegedus / Firebase Functions Graphql Example
Programming Languages
Projects that are alternatives of or similar to Firebase Functions Graphql Example
deprecated, new example at firebase-gcp-examples
🚨GraphQL Server on Cloud Functions for Firebase
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.
TLDR;
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.
Routes
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>
Installation
git clone https://github.com/jthegedus/firebase-functions-graphql-example
cd firebase-functions-graphql-example
yarn install
Local Development
yarn serve
This will serve the Cloud Functions locally using the Firebase emulator.
Deploy to Firebase
yarn deploy
N.B.: Replace <project-name>
in the .firebaserc
to connect the project to your Firebase project.
A note on Code Compatibility
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.