cover-img

Creating an email custom scalar to Apollo GraphQL

10 October, 2022

2

2

0

In this tutorial i will show how to implement an Email custom scalar to Apollo GraphQL.
Implement an email scalar isn’t a hard task but i will show in details.
You must implement the functions __parseValue, __serialize and __parseLiteral.
We need a regex to check the email, in this tutorial i used this one:
img
First we must implement the __parseValue function. Basically we will just test the input type and check the input with our Regex:
__parseValue
img
After this we will implement the __serialize function , in our example let’s just return the value:
__serialize
img
And finally lets implement the __parseLiteral function , we will check the literal kind and check our regex with literal value:
__parseLiteral
img
And that’s it ! Our email custom scalar is done. You can check the complete code and the unit test below:
I hope this helps !

2

2

0

Kevin Martins
A telecommunications engineer who likes to write codes

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.