-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type evaluator: Add support for delta mode queries #276
base: main
Are you sure you want to change the base?
Conversation
t.test('delta mode', (t) => { | ||
const variants = [ | ||
{ | ||
query: `*[_type == "author" && before()._type == "other"]`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really how before()
should be used though. It's technically a correct example, but it doesn't use the scope, but rather refers to the before
/after
values in the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we operate on the types and not values. The only case where we can know the value if it's a string literal. I get that comparing _type like this is not realistic per se, but I wanted to test wether it would exclude all types, practically the same as _type == "author" && _type == "other"
which would always return an empty set.
switch (node.key) { | ||
case 'before': | ||
case 'after': { | ||
return scope.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit off. before()
and after()
shouldn't refer to scope
. It just uses the context: https://spec.groq.dev/draft/#global_before(). We can maybe assume that it's an element of schema
, although technically we should probably rather introduce a new option to typeEvaluate
which lets you specify the type of this value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not retuning the scope, it's returning the current value that's in the scope. Which is the current schema that hasn't been filtered out
No description provided.