I would like to construct my FQL queries in VSCode for the reasons stated in other posts on this issue. I apologize for the question to extend beyond Fauna specifically, however, the issue is one of cross platform compatibility and integration so this is unavoidable to a large degree (and anyway applicable to all the technology domains taken discreetly).
I found a potentially useful tutorial here.
I have an issue with that tutorial that I have posted on GitHub which is preventing me from simply following the tutorial.
However, my main objective, currently, is to better understand the relationship between typescript and how to more easily construct FQL functions in VSCode which is why I am posting these questions here.
Given that DetermineResult.ts is a âpureâ typescript file, am I then effectively writing a significant portion of my FQL queries in typescript? Thatâs fine if I am, however, attempting to incorporate this in my project (or even just the tutorial) raises further issues:
When I copy/paste (because the VSCode terminal upload doesnât currently work) the âQueryâ part of this FQL from the tutorial into the Fauna Dashboard âplayâ function definition my function FQL becomes:
{
name: "play",
role: null,
body: Query(
Lambda(
["selection"],
Let(
{
randomCharacter: RandomString(1, "RPS"),
opponentSelection: Switch(Var("randomCharacter"), selectionMap)
},
DetermineResult(Var("selection"), Var("opponentSelection"))
)
)
)
}
However, I then get:
RandomString is not defined.
In Fauna Dashboard.
RandomString is imported in the Play.ts file:
import { RandomString, Switch } from "faunadb-fql-lib";
If functions like RandomString from âfaunadb-fql-libâ are not recognized by Fauna then how can they be used in the typescript files?
If I resolve this question I suspect I will face a similar issue in relation to DetermineResult
The tutorial states:
âThis is our UDF. Note that it references the DetermineResult helper function we created above.â
How? Perhaps I am not understanding well enough how node packages can be used in a context like this?
My questions from above (listed for reference):
- Am I then effectively writing a significant portion of my FQL queries in typescript, or is that the wrong way to think about this?
- If functions like RandomString from âfaunadb-fql-libâ are not recognized by Fauna then how can they be used in the typescript files?
- How is DetermineResult referenced? Is it managed somehow by the package?
Thanks âŚ