GraphQL on endpoint

Serverless technology is enabling us to easy deploy code without doing any system administration. One of the companies providing a serverless service is, as quoted from their website:

All you need is code,
Make serverless endpoints

For curiosity and learning purposes I wanted to get something running on a endpoint so I decided to create a GraphQL server with Node.js

Enabling on your development environment

The first step was to get the enabled on my development environment for creating the GraphQL HTTP endpoint with Node.js.
the command line interface (CLI) seemed for me most suitable because it enables the possibility to run the code locally.

Follow these instructions if you want to install the command line interface(cli) on your own development environment.

Setup GraphQL server with express

Second step was to enable the GraphQL server and have it tested locally.
Webtask provides several programming models out of the box and it would be possible to run GraphQL with the Simple function model But because it is a little more easy to get GraphQL running with express it was best to go for the Custom programming model utilizing the webtask-tools package provided by Auth0

Coming up with the following example code to create the GraphQL server with express.

Interesting detail here is the ‘use latest’ statement on line 1 that tells webtask to run the code on the latest version of Node.js enabling some features that we want without transpiling.

Before running this code on we can test it locally with the webtask cli tools.

$ wt-cli serve graphql.js
Your webtask is now listening for IPv4 traffic on

Then making a test request and see if all is running fine we could issue the following curl command

$ curl -X POST \ \
-H 'content-type: application/json' \
-d '{"query" : "{ hello }"}'

The expected response would be

{"data":{"hello":"Hello world!"}}

Deploy to

finally to deploy the code to all we have todo is execute the following command

$ wt create --name graphql graphql.js
* Hint: A package.json file has been detected adjacent to your webtask. Ensuring that all dependencies from that file are available on the platform. This may takea few minutes for new versions of modules so please be patient.
* Hint: If you would like to opt-out from this behaviour, pass in the --ignore-package-json flag.
Resolving 5 modules...
Provisioning 5 modules...
body-parser@1.18.2 is available
express@4.16.2 is available
express-graphql@0.6.11 is available
graphql@0.11.7 is available
webtask-tools@3.2.0 is available
Webtask created
You can access your webtask at the following url:

Then to test that all is working go to your favorite browser and copy paste the link and the graphiql explorer should open and u can perform the hello query and should get some nice result as shown in the image below.

Finally lets test with making a request with curl from the command line

curl -X POST \
> \
> -H 'content-type: application/json' \
> -d '{"query" : "{ hello }"}'

The expected response would be the same as before

{"data":{"hello":"Hello world!"}}


With just a few lines of code we can have a GraphQL server running with the least amount of effort on a endpoint.


Repository with the full code base can be found here


Found any technical error? please submit it to me and I will correct the page as soon as possible also note I am not a English native so any grammatical errors please notify me and I will correct them.


Like what you read? Give Boris Verhaaff a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.