Getting started with GraphQL
Queries and Mutations
GraphQL 서버에 어떻게 query 할 것인가?
example query
{
hero{
name
}
}
arguments
{
human(id: "1000"){
name
height
}
}
alias
{
empireHero: hero(episode: EMPIRE){
name
}
jediHero:hero(eposode:JEDI){
name
}
}
fragments
reusable units called fragments
query HeroComparison($first: Int = 3){
leftComparison: hero(episode: EMPIRE){
...comparisonFields
}
rightComparison: hero(episode: JEDI){
...comparisonFields
}
}
fragment comparisonFields on Character{
name
friendConnection(first: $first){
totalCount
edges{
node{
name
}
}
}
}
varables
query HeroNameAndFriends($episode: Episode){
hero(eposide: $episode){
name
friends{
name
}
}
}
now, in our client code we can simply pass a different variable rather than needing to constructor an entirely new query.
directives
query Hero($episode: Episode, $withFriends: hero(episode: $episode){
hero(episode: $episode){
name
friends @include(if:$withFriends){
name
}
}
})