Can't get Fauna to work with nodejs and cloudflare worker


As my first test project I decided to make a simple app: have a database of a movie watchlist and allow users to search an imdb id and return some information about that movie from the database.

This query works in my javascript code (get by document id):
const result = await faunaClient.query(q.Get(q.Ref(q.Collection(params.type),

This query works on the fql shell:

Call(Function("movie_by_id"), "tt0133093")

This query does NOT work in the javascript:

const result = await faunaClient.query(q.Call(q.Function(“movie_by_id”),“tt0133093”))

I get: "“error”:“StatusError: BadRequest: invalid argument”

Here is the UDF:

      { movie: Select(["data"], Get(Match(Index("test"), Var("ID")))) },

Hi @mkavidas and welcome!

Based on the error, I don’t think that the content of the query is the issue but how the query is communicated to Fauna.

We’d need some further details to help you diagnose the problem. Can you show us how you create the Fauna client object (without disclosing the secret that you are using)?

And can you show us any error handling code that you might be using? We might be able to suggest some adjustments that would aid debugging.