Introducing new capabilities for teams, third-party authentication and real-time database streaming!
Fauna logo
Log InSign Up
Fauna logo
Sign Up
© 2021 Fauna, Inc. All Rights Reserved.
<- Back
Screen Shot 2019 12 18 at 4 58 12 PM

Announcing UDF in Console

Lewis King|Dec 19th, 2019|



We’re pleased to announce the release of user-defined function (UDF) support in the Fauna Console! While UDFs have been available in FQL for some time, they can now be easily managed using the Console GUI.

Generally speaking, a UDF is comparable to a stored procedure or server-side function that has its parameters set by a user and often is seen as a “programming shortcut”. In Fauna, UDFs are FQL Lambda functions (which can be anonymous), and they can be exposed through the GraphQL API, by using the @resolver directive on fields in the Query and Mutation types. You can learn more about Fauna GraphQL UDFs in our documentation.

UDFs in action

Creating UDFs in the Console is quite simple. From the homepage, click on one of your Databases. In the left-hand navigation bar, click on the “Functions” button and then click the green “New Function button”:

blog post image

You’ll then see the New Function screen. For this example, let’s create a function that simply doubles the input for a query (more advanced examples are given here). This query adds the variable “x” to itself, thereby doubling it.

Let’s call the function “double”, and specify the function body as:

Lambda('x', Add(Var('x'), Var('x')))
blog post image

Once saved, you should see the function listed in the Functions list:

blog post image

Note: you can use the Role field to apply a role’s privileges to a UDF, which is how you specify permissions in Fauna.

You can create more functions at your whim, and delete functions when needed:

blog post image

Using your new function is straightforward as well. Simply wrap the function name in quotes in a Call()command, i.e. Call("double", 2):

blog post image

And that’s about it! When it comes to UDFs, the only limit is your creativity 😉


With our latest cloud release, users now have the ability to create and manage UDFs for a database directly in the Fauna Console.

Visit our documentation to learn more. Please reach out to me on Twitter and our Community Slack and describe any other features that would make Fauna an obvious choice for your next project.

If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, serverless databases, GraphQL, and Jamstack, Fauna is hiring!

Share this post


Subscribe to Fauna blogs & newsletter

Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.

<- Back