This is a GraphQL backend boilerplate in nodejs that can be deployed on Google Cloud Functions.
node 8.10
Google Cloud Functions
Apollo Server (GraphQL framework)
type Query {
hello: String
}
The sample source code is present in index.js
.
$ git clone [email protected]:hasura/graphql-engine
$ cd graphql-engine/community/boilerplates/remote-schemas/google-cloud-functions/nodejs
Start a local development server (you may need to install dependencies from npm):
$ npm i --no-save apollo-server
$ node localDev.js
Output:
Server ready at http://localhost:4000/
This will start a local server on localhost:4000
. You can hit the graphql service at localhost:4000
. This opens a graphql playground where you can query your schema.
-
Install
gcloud
cli. -
From the current directory, run the following command to deploy the function:
$ gcloud functions deploy hello-graphql --entry-point handler --runtime nodejs8 --trigger-http
- Get the trigger URL from the above output:
httpsTrigger:
url: https://us-central1-hasura-test.cloudfunctions.net/hello-graphql