These are the queries that were used in the video. Try playing around with them till you feel comfortable. You may also check out the official docs for GraphQL query.
{
viewer {
# query can have comments too!
# shape of data is maintained
name
}
}
{
viewer {
name
# fields can refer to objects
status {
# requesting status fields
emoji
message
}
}
}
{
viewer {
name
# passing arguements to field
organization(login: "wtjs") {
name
}
}
}
{
# aliasing query results
lovesMountains: user(login: "divyanshu013") {
name
}
lovesBeaches: user(login: "metagrover") {
name
}
}
{
lovesMountains: user(login: "divyanshu013") {
...userFields
}
lovesBeaches: user(login: "metagrover") {
...userFields
}
}
# creating a reusable fragment
fragment userFields on User {
name
bio
}
# Add an operation type and name
query GetViewer {
viewer {
name
}
}
# Adding a $login variable. Notice the !
query GetUser($login: String!) {
user(login: $login) {
name
}
}
{
"login": "divyanshu013"
}
# Adding a $login default variable
query GetUser($login: String = "divyanshu013") {
user(login: $login) {
name
}
}
{
}
# Using directives @include @skip
query GetUser($withBio: Boolean!) {
user(login: "divyanshu013") {
name
bio @include(if: $withBio)
}
}
{
"withBio": true
}
# Meta fields
query GetViewer {
viewer {
__typename
name
}
}