Projects STRLCPY graphql-engine Files
🤬
..
graphql Loading last commit info...
.gitignore
README.md
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 [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.

Deployment

  1. Install az cli.

  2. Create a zip of all resources (from the current directory):

$ zip -r graphql.zip *
  1. 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

  1. 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

Please wait...
Page is in error, reload to recover