This is a GraphQL backend boilerplate in nodejs that can be deployed on Azure Functions.
node 8.10
Azure Functions
Apollo Server (GraphQL framework)
type Query {
hello: String
}
The sample source code is present in graphql
folder.
$ git clone [email protected]: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.
Install az
cli.
Create a zip of all resources (from the current directory):
$ zip -r graphql.zip *
$ 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
$ 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