add worldByName
This commit is contained in:
parent
27e17fe2ec
commit
ec802674ef
1 changed files with 20 additions and 2 deletions
|
@ -10,8 +10,8 @@ pub struct Query;
|
||||||
|
|
||||||
#[graphql_object(context = Context)]
|
#[graphql_object(context = Context)]
|
||||||
impl Query {
|
impl Query {
|
||||||
fn world(id: ID) -> FieldResult<Option<World>> {
|
fn world(id: ID) -> FieldResult<World> {
|
||||||
Ok(Some(World { id }))
|
Ok(World { id })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allWorlds() -> FieldResult<Vec<World>> {
|
fn allWorlds() -> FieldResult<Vec<World>> {
|
||||||
|
@ -42,6 +42,24 @@ impl Query {
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn worldByName(name: String) -> FieldResult<World> {
|
||||||
|
let id = match name.to_lowercase().as_str() {
|
||||||
|
"connery" => "1",
|
||||||
|
"niller" => "10",
|
||||||
|
"cobalt" => "13",
|
||||||
|
"emerald" => "17",
|
||||||
|
"jaeger" => "19",
|
||||||
|
"soltech" => "40",
|
||||||
|
"genudine" => "1000",
|
||||||
|
"ceres" => "2000",
|
||||||
|
_ => "1",
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(World {
|
||||||
|
id: ID::from(id.to_string()),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
|
|
Loading…
Add table
Reference in a new issue