mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
d6a3cf337f
A hello world schema is provided with local dev and deployment instructions for AWS Lambda, Google Cloud Functions and Azure Functions. Older boilerplates are cleaned up. |
||
---|---|---|
.. | ||
graphql | ||
.gitignore | ||
host.json | ||
README.md |
Azure Functions + NodeJS + Apollo
This is a GraphQL backend boilerplate in nodejs that can be deployed on Azure Functions.
Stack
node 8.10
Azure Functions
Frameworks/Libraries
Apollo Server (GraphQL framework)
Schema
type Query {
hello: String
}
Local Development
The sample source code is present in graphql
folder.
$ git clone git@github.com:hasura/graphql-engine
$ cd graphql-engine/community/boilerplates/remote-schemas/azure-functions/nodejs
Start a local development server (you may need to install dependencies from npm):
$ cd graphql
$ npm i --no-save apollo-server express
$ 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
az
cli. -
Create a zip of all resources (from the current directory):
$ zip -r graphql.zip *
- Run the following commands to deploy:
$ az group create --name 'my-functions-group' --location southindia
$ az storage account create --name 'myfunctionsstorage' --location southindia --resource-group 'my-functions-group' --sku Standard_LRS
$ az functionapp create --name 'hello-graphql' --storage-account 'myfunctionsstorage' --resource-group 'my-functions-group' --consumption-plan-location southindia
$ az functionapp deployment source config-zip -g "my-functions-group" -n "hello-graphql" --src graphql.zip
- Get the HTTP Url:
$ az functionapp show -g "my-functions-group" -n "hello-graphql"
Output:
"hostNames": [
"hello-graphql.azurewebsites.net"
],
The url of the function is <hostname>/<function> e.g. in our case: https://hello-graphql.azurewebsites.net/graphql