FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppgraphqlgen/samples/learn/sample.cpp at main · wravery/cppgraphqlgen · GitHub
wravery
cppgraphqlgen
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppgraphqlgen
/
samples
/
learn
/
sample.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (44 loc) · 1.04 KB
Breadcrumbs
cppgraphqlgen
/
samples
/
learn
/
sample.cpp
Copy path
File metadata and controls
57 lines (44 loc) · 1.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
Copyright (c) Microsoft Corporation. All rights reserved.
//
Licensed under the MIT License.
#
include
"
StarWarsData.h
"
#
include
"
graphqlservice/JSONResponse.h
"
#
include
<
cstdio
>
#
include
<
iostream
>
#
include
<
iterator
>
#
include
<
stdexcept
>
using
namespace
graphql
;
int
main
(
int
argc,
char
** argv)
{
auto
service =
star_wars::GetService
();
std::cout <<
"
Created the service...
"
<< std::endl;
try
{
peg::ast query;
if
(argc >
1
)
{
query =
peg::parseFile
(argv[
1
]);
}
else
{
std::istream_iterator<
char
> start { std::cin >> std::noskipws }, end {};
std::string input { start, end };
query =
peg::parseString
(
std::move
(input));
}
if
(!query.
root
)
{
std::cerr <<
"
Unknown error!
"
<< std::endl;
std::cerr << std::endl;
return
1
;
}
std::cout <<
"
Executing query...
"
<< std::endl;
std::cout <<
response::toJSON
(
service->
resolve
({ query, ((argc >
2
) ? argv[
2
] :
"
"
) }).
get
())
<< std::endl;
}
catch
(
const
std::runtime_error& ex)
{
std::cerr << ex.
what
() << std::endl;
return
1
;
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL