MCPcopy Create free account
hub / github.com/comnik/declarative-dataflow / graph_ql

Function graph_ql

tests/pull_test.rs:166–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164#[test]
165#[rustfmt::skip]
166fn graph_ql() {
167 use declarative_dataflow::plan::GraphQl;
168 use declarative_dataflow::binding::Binding;
169
170 let transactions = vec![vec![
171 TxData::add(100, "name", Value::from("Alice")),
172 TxData::add(100, "hero", Bool(true)),
173 TxData::add(200, "name", Value::from("Bob")),
174 TxData::add(200, "hero", Bool(true)),
175 TxData::add(300, "name", Value::from("Mabel")),
176 TxData::add(300, "hero", Bool(true)),
177 TxData::add(400, "name", Value::from("Dipper")),
178 TxData::add(400, "hero", Bool(true)),
179
180 TxData::add(300, "bested", Eid(400)),
181 TxData::add(200, "bested", Eid(100)),
182
183 TxData::add(300, "age", Number(13)),
184 TxData::add(400, "age", Number(12)),
185 ]];
186
187 // We want to pull all entities carrying the `hero` attribute.
188 let root_plan = declarative_dataflow::q(vec![0], vec![
189 // <- arbitrary symbol here to fake a placeholder
190 Binding::attribute(0, "hero", 11111),
191 ]);
192
193 run_cases(vec![
194 {
195 let q = "{name age height mass}";
196
197 let expectations = vec![vec![
198 (vec![Eid(100), Value::aid("name"), Value::from("Alice")], 0, 1),
199 (vec![Eid(200), Value::aid("name"), Value::from("Bob")], 0, 1),
200 (vec![Eid(300), Value::aid("name"), Value::from("Mabel")], 0, 1),
201 (vec![Eid(400), Value::aid("name"), Value::from("Dipper")], 0, 1),
202 (vec![Eid(300), Value::aid("age"), Number(13)], 0, 1),
203 (vec![Eid(400), Value::aid("age"), Number(12)], 0, 1),
204 ]];
205
206 Case {
207 description: q,
208 plan: Plan::GraphQl(GraphQl::with_plan(root_plan.clone(), q.to_string())),
209 transactions: transactions.clone(),
210 expectations,
211 }
212 },
213 {
214 let q = "{name bested { name }}";
215
216 let expectations = vec![vec![
217 (vec![Eid(100), Value::aid("name"), Value::from("Alice")], 0, 1),
218 (vec![Eid(200), Value::aid("name"), Value::from("Bob")], 0, 1),
219 (vec![Eid(300), Value::aid("name"), Value::from("Mabel")], 0, 1),
220 (vec![Eid(400), Value::aid("name"), Value::from("Dipper")], 0, 1),
221 (vec![Eid(300), Value::aid("bested"), Eid(400), Value::aid("name"), Value::from("Dipper")], 0, 1),
222 (vec![Eid(200), Value::aid("bested"), Eid(100), Value::aid("name"), Value::from("Alice")], 0, 1),
223 ]];

Callers

nothing calls this directly

Calls 2

qFunction · 0.85
run_casesFunction · 0.70

Tested by

no test coverage detected