update examples

This commit is contained in:
everyone 2023-11-04 22:52:59 -07:00
parent e52cf7009b
commit f66fc290fd
Signed by: everyone
SSH Key Fingerprint: SHA256:FKcGHdUnp2OocVUUAEJV25QetYQXwbmKPSsblofJOrM
2 changed files with 12 additions and 14 deletions

View File

@ -1,31 +1,30 @@
use graphql_query_builder::{Builder, InputValues, OperationType, SelectionSet};
use std::collections::HashMap;
use graphql_query_builder::{json, Builder, OperationType, SelectionSet};
pub fn query() -> String {
let vec = vec![
SelectionSet {
operation: String::from("id"),
operation: "id",
alias: None,
fields: None,
arguments: None,
is_union: false,
},
SelectionSet {
operation: String::from("name"),
operation: "name",
alias: None,
fields: None,
arguments: None,
is_union: false,
},
SelectionSet {
operation: String::from("profilePic"),
operation: "profilePic",
alias: Some("smallPic"),
fields: None,
arguments: None,
is_union: false,
},
SelectionSet {
operation: String::from("profilePic"),
operation: "profilePic",
alias: Some("bigPic"),
fields: None,
arguments: None,
@ -33,10 +32,10 @@ pub fn query() -> String {
},
];
let user = SelectionSet {
operation: String::from("user"),
operation: "user",
alias: None,
fields: Some(vec),
arguments: Some(HashMap::from([("id", InputValues::Int(4))])),
arguments: json!({ "id": 4 }),
is_union: false,
};
Builder::new(OperationType::Query, &user)

View File

@ -1,12 +1,11 @@
use graphql_query_builder::{Builder, InputValues, OperationType, SelectionSet};
use std::collections::HashMap;
use graphql_query_builder::{json, Builder, OperationType, SelectionSet};
pub fn query() -> String {
let story = SelectionSet {
operation: String::from("Story"),
operation: "Story",
alias: None,
fields: Some(vec![SelectionSet {
operation: "likeCount".to_string(),
operation: "likeCount",
alias: None,
fields: None,
arguments: None,
@ -16,10 +15,10 @@ pub fn query() -> String {
is_union: false,
};
let like_story = SelectionSet {
operation: String::from("likeStory"),
operation: "likeStory",
alias: None,
fields: Some(vec![story]),
arguments: Some(HashMap::from([("storyID", InputValues::Int(12345))])),
arguments: json!({ "storyID": 12345 }),
is_union: false,
};
Builder::new(OperationType::Mutation, &like_story)