Looking for the Prisma documentation? You can find it here

Functions

Last updated a day ago Edit this page

#What is a managed function?

A managed function is a function that's managed and deployed by Graphcool (think of Graphcool as your FaaS provider for managed functions). If you're using a managed function in your Graphcool project, all you need to do is write the code for it, add it to your service definition file and run graphcool deploy. Graphcool will then make sure the function is deployed for you

#In what environment are managed functions executed with Graphcool? Can I use ES6 for my JS code?

Functions are executed with Auth0 Extend. You can use ES6 if you write the string 'use-latest' in the first line of your function. You can read more about the runtime environment here.

#How can I validate and transform the payload of a request before data gets written to the database?

There are two ways of doing this:

For simple use cases, such as validating an email address or sanitizing a credit card number, using a hook function is usually a good choice.

#What is the graphcool-lib and how can I use it?

The graphcool-lib provides a convenient interface to the Graphcool system:

Here's some functionality it offers:

  • convenience API for sending queries and mutations to a Graphcool service (based on graphql-request)
  • generating a temporary authentication token for a node in your database

If you want to use it inside a managed function, you can simply require it (similar to here). In a webhook, you can install it as a dependency with npm.

Was this page helpful?

Recommended