graphql-engine/community/boilerplates/remote-schemas/azure-functions/nodejs
Tirumarai Selvan d6a3cf337f add hello-world remote-schema boilerplates for major serverless providers (#1694)
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.
2019-03-05 21:45:39 +05:30
..
graphql add hello-world remote-schema boilerplates for major serverless providers (#1694) 2019-03-05 21:45:39 +05:30
.gitignore add hello-world remote-schema boilerplates for major serverless providers (#1694) 2019-03-05 21:45:39 +05:30
host.json add hello-world remote-schema boilerplates for major serverless providers (#1694) 2019-03-05 21:45:39 +05:30
README.md add hello-world remote-schema boilerplates for major serverless providers (#1694) 2019-03-05 21:45:39 +05:30

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

  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