We’re overhauling Dgraph’s docs to make them clearer and more approachable. If
you notice any issues during this transition or have suggestions, please
let us know.
Schema
To set up a lambda query, first you need to define it on your GraphQL schema by using the@lambda
directive.
get
, query
, and aggregate
are reserved prefixes and they can’t be used
to define Lambda queries.Author
that finds out authors given
an author’s name
:
Resolver
Once the schema is ready, you can define your JavaScript query function and add it as resolver in your JS source code. To add the resolver you can use either theaddGraphQLResolvers
or addMultiParentGraphQLResolvers
methods.
A Lambda Query resolver can use a combination of
parents
, args
, dql
, or
graphql
inside the function.This example uses
dql
for the resolver function. You can find additional
resolver examples using parent
in the Lambda fields article, and
using graphql
in the Lambda mutations article.authorsByName()
lambda function and add
it as resolver: