Building URL shortener using React, Apollo, and GraphQL — Part III

Peter Jausovec
HackerNoon.com

--

Photo by Chris Kristiansen (https://unsplash.com/@chriskristiansen)

Table of Contents

Part III: Creating serverless function for hashing

In this post we are going to take the hashing function we implemented in the previous post and move it to the Graphcool functions.

Functions need to be defined in the Graphcool service definition file (graphcool.yml). Graphcool supports the following function types that can be invoked either as webhooks or as managed functions:

Before and after operations (operationBefore/operationAfter)

For this to work, you need to specify the operation on a model for which the function should be invoked. For example: Link.update, Link.delete or Link.create. An example for when this type could be used is if we wanted to implement a feature that prevents certain users from creating more than X number of links. We could use the operationBefore on Link.create and…

--

--