Last active
August 13, 2019 23:43
-
-
Save iancormac84/115c5ba97b7cb13bab02f0f0fb17d545 to your computer and use it in GitHub Desktop.
Gist displaying GraphQL, JSON, and Rust code snippets for help question.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"errors":[ | |
{ | |
"message":"Variable \"$input\" expected value of type \"Owner\" which cannot be used as an input type.", | |
"locations":[ | |
{ | |
"line":1, | |
"column":19 | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let input = Owner::new( | |
"John".to_string(), | |
"Doe".to_string(), | |
Some("Strange".to_string()), | |
Gender::Male, | |
vec!["+14687210744573"], | |
vec!["example@gmail.com"] | |
).unwrap(); | |
let query = | |
r#"mutation AddOwner($input: Owner) { | |
addOwner(input: $input) { | |
id | |
} | |
}"#; | |
let value = json!({ | |
"query": query, | |
"variables": { | |
"input": input | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"query":"mutation AddOwner($input: Owner) {\n addOwner(input: $input) {\n id\n }\n }", | |
"variables":{ | |
"input":{ | |
"_id":{ | |
"$oid":"5d53488f005b23ea00c14f59" | |
}, | |
"first_name":"John", | |
"surname":"Doe", | |
"other_names":"Strange", | |
"gender":"Male", | |
"contact_numbers":[ | |
"+14687210744573" | |
], | |
"email_addresses":[ | |
"example@gmail.com" | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Gender { | |
Male | |
Female | |
} | |
type Owner { | |
id: ObjectId! | |
firstName: String! | |
surname: String! | |
otherNames: String | |
gender: Gender! | |
contactNumbers: [String]! | |
emailAddresses: [String]! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment