Open carlpeaslee opened 1 year ago
Internal ticket number is FE-2847
Hi @carlpeaslee, thanks for bringing this up! I'll take a look and get back to you.
@carlpeaslee Are you able to share code?
@carlpeaslee this patch was motivated by the decision to validate that Client query arguments match existing typescript types. This just changes where the query gets denied, in the driver itself instead of as a 400 response from the database.
In your case it's exposing the fact that your ExprArg
value (claim_links_id_unique.ref
) is undefined
at the moment your query is submitted to the driver. It doesn't make it to faunadb. Also this javascript driver doesn't do any static analysis of your query. The FQL query function is not "lazy loaded", it's simply executed immediately as it's evaluated in your file during runtime. So it's up to you to ensure that claim_links_id_unique
exists before you define this query that uses its ref.
I'm not sure exactly how this would look without knowing more of your code and test framework. But it's a matter of waiting for one fauna query to finish before defining another query that depends on the first query's completion.
For now we want to leave this change in as a patch, because it matches existing typescript definitions. Depending on your and other's feedback we would consider making this a major version change.
thanks for the helpful responses. I will try to get back to you all soon with more code.
I get the following error after upgrading from 4.7.0 to 4.7.1. The actual occurs when a test imports code that defines FQL that includes variables which reference other FQL. In this case
claim_links_id_unique.ref
=Index('claim_links_id_unique')
.This code runs fine (and actually isn't even executed by the test that fails since it's defining a UDF). My guess is that
faunadb
is doing some kind of pre-run static analysis and for whatever reason, because of the order of imports,claim_links_id_unique.ref
isundefined
at the timefaunadb
does its analysis?Also apologies, I didn't see a template for filing issues so let me know if there is additional information you'd like.
cc @thomas-franceschi