Skip to content

Commit

Permalink
feat(typeEvaluator): add support for dateTime::now()
Browse files Browse the repository at this point in the history
  • Loading branch information
sgulseth committed Jun 19, 2024
1 parent d8cf2d9 commit 9ad8200
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/typeEvaluator/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export function handleFuncCallNode(node: FuncCallNode, scope: Scope): TypeNode {
return {type: 'null'}
})
}
case 'dateTime.now': {
return {type: 'string'}
}
case 'global.now': {
return {type: 'string'}
}
Expand Down
9 changes: 8 additions & 1 deletion test/typeEvaluate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,8 @@ t.test('function: global::round', (t) => {

t.test('function: global::now', (t) => {
const query = `*[_type == "post"] {
"now": now()
"now": now(),
"dateTimeNow": dateTime::now()
}`
const ast = parse(query)
const res = typeEvaluate(ast, schemas)
Expand All @@ -2147,6 +2148,12 @@ t.test('function: global::now', (t) => {
type: 'string',
},
},
dateTimeNow: {
type: 'objectAttribute',
value: {
type: 'string',
},
},
},
},
})
Expand Down

0 comments on commit 9ad8200

Please sign in to comment.