Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

[RFC] Support for tagged template literals

$
0
0

I’m testing this out with Fauna and I am hitting a snag.

Here’s some code:

// binding
@module("fauna")
external fql: (array<string>, array<string>) => query = "fql"

// usage
let postQuery = fql`blog.all()`

// output
var postQuery = Fauna.fql(["blog.all()"], []);

Fauna throws an error Error: invalid query constructed.

I did some poking and the way to resolve this is to remove the second array:

var postQuery = Fauna.fql(["blog.all()"]);

I also tried querying by an id to see what happened if I pass a parameter.

let id = "388452496460218432"
let postQuery = fql`blog.byId(${id})`
let posts = await client.query(postQuery)

// output
var postQuery = Fauna.fql([
      "blog.byId(",
      ")"
    ], ["388452496460218432"]);
var posts = await client.query(postQuery);

This has a different fauna error: QueryCheckError: The query failed 1 validation check


Viewing all articles
Browse latest Browse all 2592

Trending Articles