Write videogame search query

This commit is contained in:
Kiana Sheibani 2023-08-26 23:48:13 -04:00
parent 5fdc8cb50e
commit a1e23b453d
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
4 changed files with 42 additions and 0 deletions

7
cli/build.rs Normal file
View file

@ -0,0 +1,7 @@
fn main() {
cynic_codegen::register_schema("startgg")
.from_sdl_file("../schema/src/startgg.graphql")
.unwrap()
.as_default()
.unwrap();
}

View file

@ -1,5 +1,9 @@
use std::env;
mod queries;
use queries::*;
fn get_auth_key() -> Option<String> {
env::var("AUTH_KEY").ok()
}

2
cli/src/queries.rs Normal file
View file

@ -0,0 +1,2 @@
mod search_games;

View file

@ -0,0 +1,29 @@
use schema::schema;
// VARIABLES
#[derive(cynic::QueryVariables)]
pub struct VideogameSearchVars {
name: String
}
// QUERY
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "VideogameSearchVars")]
pub struct VideogameSearch {
#[arguments(query: { filter: { name: $name }, page: 1, perPage: 10 })]
pub videogames: Option<VideogameConnection>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct VideogameConnection {
pub nodes: Option<Vec<Option<Videogame>>>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct Videogame {
pub id: Option<cynic::Id>,
pub name: Option<String>,
}