Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Eelco van der Wel
Graphql Test
Commits
260620da
Commit
260620da
authored
3 years ago
by
Alp Deniz Ogut
Browse files
Options
Download
Email Patches
Plain Diff
Use gql file for ease
parent
f7c9971c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
graph_query.gql
+5
-0
graph_query.gql
src/main.rs
+7
-4
src/main.rs
with
12 additions
and
4 deletions
+12
-4
graph_query.gql
0 → 100644
+
5
-
0
View file @
260620da
query
{
uid
(
id
:
"5"
)
{
age
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main.rs
+
7
-
4
View file @
260620da
use
core
::
panic
;
use
std
::
fs
;
use
std
::
error
::
Error
;
use
graphql_parser
::
query
::
Field
;
use
graphql_parser
::
query
::
OperationDefinition
;
...
...
@@ -13,15 +15,16 @@ fn print_type_of<T>(_: &T) {
}
fn
main
()
{
fn
main
()
->
Result
<
(),
Box
<
dyn
Error
>>
{
let
query_string
=
fs
::
read_to_string
(
"graph_query.gql"
)
?
;
// let str = String::from("query { queryPersons{ name } }");
let
str
=
String
::
from
(
"
query
{ uid(id:
\"
0x1000
\"
) { age } }"
);
let
str
=
String
::
from
(
query
_string
);
let
res
=
parse_query
::
<
String
>
(
&
str
)
.unwrap
()
.to_owned
();
println!
(
"{}"
,
res
);
println!
(
"{}"
,
res
.definitions
.len
());
for
def
in
res
.definitions
{
Ok
(
for
def
in
res
.definitions
{
if
let
Definition
::
Operation
(
op
)
=
def
{
if
let
OperationDefinition
::
Query
(
query
)
=
op
{
...
...
@@ -41,7 +44,7 @@ fn main() {
}
else
{
panic!
(
"Fragments are not supported"
);
}
}
}
)
}
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