mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 09:51:59 +03:00
.. | ||
.gcloudignore | ||
.gitignore | ||
googleCtx.js | ||
index.js | ||
localDev.js | ||
package.json | ||
README.md |
Google Cloud Functions + NodeJS + Apollo
This is a GraphQL backend boilerplate in nodejs that can be deployed on Google Cloud Functions.
Stack
node 8.10
Google Cloud Functions
Frameworks/Libraries
Apollo Server (GraphQL framework)
Schema
type Query {
hello: String
}
Local Development
The sample source code is present in index.js
.
$ git clone git@github.com: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.
Deployment
-
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