Cloud Functions can accept an Express.js server as it's params as they share a similar request/response object (as discussed here). Using the apollo-server-express
package we can quickly and easily setup a GraphQL server on FaaS.
The accompanying Medium post.
# Install
yarn
# Locally serve
yarn serve
# Deploy
yarn deploy
GraphQL Playground: https://us-central1-<project-id>.cloudfunctions.net/api
GraphQL Endpoint: https://us-central1-<project-id>.cloudfunctions.net/api/graphql
Go to the GraphQL Playground route and enter the GraphQL endpoint route into the GraphQL Server address bar to connect the playground to your endpoint. Now you can query away and develop your app!
Here's the test query:
{
hello
}