FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppgraphqlgen/samples/learn/StarWarsData.cpp at main · wravery/cppgraphqlgen · GitHub
wravery
/
cppgraphqlgen
Public
forked from
microsoft/cppgraphqlgen
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppgraphqlgen
/
samples
/
learn
/
StarWarsData.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
121 lines (97 loc) · 3.01 KB
Breadcrumbs
cppgraphqlgen
/
samples
/
learn
/
StarWarsData.cpp
Copy path
File metadata and controls
121 lines (97 loc) · 3.01 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
Copyright (c) Microsoft Corporation. All rights reserved.
//
Licensed under the MIT License.
#
include
"
StarWarsData.h
"
#
include
"
DroidData.h
"
#
include
"
HumanData.h
"
#
include
"
MutationData.h
"
#
include
"
QueryData.h
"
#
include
"
ReviewData.h
"
using
namespace
std
::literals
;
namespace
graphql
::star_wars {
std::shared_ptr<service::Request>
GetService
()
noexcept
{
auto
luke = std::make_shared<learn::Human>(
"
1000
"
s,
std::make_optional
(
"
Luke Skywalker
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::make_optional
(
"
Tatooine
"
s));
auto
vader = std::make_shared<learn::Human>(
"
1001
"
s,
std::make_optional
(
"
Darth Vader
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::make_optional
(
"
Tatooine
"
s));
auto
han = std::make_shared<learn::Human>(
"
1002
"
s,
std::make_optional
(
"
Han Solo
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::
nullopt
);
auto
leia = std::make_shared<learn::Human>(
"
1003
"
s,
std::make_optional
(
"
Leia Organa
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::make_optional
(
"
Alderaan
"
s));
auto
tarkin = std::make_shared<learn::Human>(
"
1004
"
s,
std::make_optional
(
"
Wilhuff Tarkin
"
s),
std::vector { learn::Episode::
NEW_HOPE
},
std::
nullopt
);
auto
threepio = std::make_shared<learn::Droid>(
"
2000
"
s,
std::make_optional
(
"
C-3PO
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::make_optional
(
"
Protocol
"
s));
auto
artoo = std::make_shared<learn::Droid>(
"
2001
"
s,
std::make_optional
(
"
R2-D2
"
s),
std::vector { learn::Episode::
NEW_HOPE
, learn::Episode::
EMPIRE
, learn::Episode::
JEDI
},
std::make_optional
(
"
Astromech
"
s));
luke->
addFriends
({
{ han },
{ leia },
{ threepio },
{ artoo },
});
vader->
addFriends
({
{ tarkin },
});
han->
addFriends
({
{ luke },
{ leia },
{ artoo },
});
leia->
addFriends
({
{ luke },
{ han },
{ threepio },
{ artoo },
});
tarkin->
addFriends
({
{ vader },
});
threepio->
addFriends
({
{ luke },
{ han },
{ leia },
{ artoo },
});
artoo->
addFriends
({
{ luke },
{ han },
{ leia },
});
std::map<learn::Episode, learn::SharedHero> heroes {
{ learn::Episode::
NEW_HOPE
, { artoo } },
{ learn::Episode::
EMPIRE
, { luke } },
{ learn::Episode::
JEDI
, { artoo } },
};
std::map<response::IdType, std::shared_ptr<learn::Human>> humans {
{ luke->
getId
(), luke },
{ vader->
getId
(), vader },
{ han->
getId
(), han },
{ leia->
getId
(), leia },
{ tarkin->
getId
(), tarkin },
};
std::map<response::IdType, std::shared_ptr<learn::Droid>> droids {
{ threepio->
getId
(), threepio },
{ artoo->
getId
(), artoo },
};
auto
query =
std::make_shared<learn::Query>(
std::move
(heroes),
std::move
(humans),
std::move
(droids));
auto
mutation = std::make_shared<learn::Mutation>();
auto
service = std::make_shared<learn::Operations>(
std::move
(query),
std::move
(mutation));
return
service;
}
}
//
namespace graphql::star_wars
Back
|
FazBrowse Home
|
New Git URL