Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Kosztka
Pod
Commits
d4b7d853
Commit
d4b7d853
authored
3 years ago
by
Eelco van der Wel
Browse files
Options
Download
Email Patches
Plain Diff
implement limit offset
parent
a04ab107
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/database_api.rs
+2
-2
src/database_api.rs
src/internal_api.rs
+32
-1
src/internal_api.rs
with
34 additions
and
3 deletions
+34
-3
src/database_api.rs
+
2
-
2
View file @
d4b7d853
...
...
@@ -310,8 +310,8 @@ pub struct GQLSearchArgs {
pub
rowids
:
Option
<
Vec
<
Rowid
>>
,
// TODO rowids should be in filters
pub
sort_property
:
String
,
pub
sort_order
:
SortOrder
,
pub
limit
:
Option
<
u
64
>
,
pub
offset
:
Option
<
u
64
>
,
pub
limit
:
Option
<
u
32
>
,
pub
offset
:
Option
<
u
32
>
,
// pub filters: Option<Vec<Filter>>,
}
...
...
This diff is collapsed.
Click to expand it.
src/internal_api.rs
+
32
-
1
View file @
d4b7d853
...
...
@@ -24,6 +24,7 @@ use crate::error::Error;
use
crate
::
error
::
Result
;
use
crate
::
graphql_utils
;
use
crate
::
graphql_utils
::
QueryASTNode
;
use
crate
::
graphql_utils
::
Argument
;
use
crate
::
plugin_auth_crypto
::
DatabaseKey
;
use
crate
::
schema
;
use
crate
::
schema
::
validate_property_name
;
...
...
@@ -454,11 +455,25 @@ fn gql_search_recursive(
item_rowids
:
Option
<
Vec
<
Rowid
>>
,
level
:
u32
)
->
Result
<
Vec
<
Value
>>
{
// TODO limit, sorting, filters
let
mut
limit
:
Option
<
u32
>
=
None
;
let
mut
offset
:
Option
<
u32
>
=
None
;
//let filters = Vec::new();
for
argument
in
&
query_ast
.arguments
{
match
argument
{
Argument
::
Limit
{
value
}
=>
limit
=
Some
(
*
value
),
Argument
::
Offset
{
value
}
=>
offset
=
Some
(
*
value
),
}
}
let
query
=
GQLSearchArgs
{
_type
:
query_ast
.item_type
.to_owned
(),
properties
:
query_ast
.properties
.to_owned
(),
rowids
:
item_rowids
,
limit
,
offset
,
..
Default
::
default
()
};
let
now
=
Instant
::
now
();
...
...
@@ -795,6 +810,22 @@ mod tests {
// print!("{:}", serde_json::to_string_pretty(&json!(data)).unwrap());
assert_eq!
(
items_with_friends
.count
(),
100
);
let
query
=
"
query {
Person (limit: 10, offset: 5) {
id
friend {
id
}
}
}"
.to_owned
();
let
res
=
graphql
(
&
tx
,
&
schema
,
query
);
let
data
=
res
.unwrap
();
let
data
=
data
.get
(
"data"
)
.unwrap
();
assert_eq!
(
data
.len
(),
10
);
}
#[test]
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets