Building URL shortener using React, Apollo, and GraphQL — Part III
Table of Contents
- Part I: Setup and displaying short URLs using GraphQL
- Part II: Creating short URLs
- Part III: Creating serverless function for hashing (this post)
- Part IV: Short URL stats (number of clicks, etc.)
- Part V: User authentication
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…