#graphql

Queries and Mutations

GraphQL 서버에 어떻게 query 할 것인가?

example query

1
2
3
4
5
{
hero{
name
}
}

arguments

1
2
3
4
5
6
{
human(id: "1000"){
name
height
}
}

alias

1
2
3
4
5
6
7
8
{
empireHero: hero(episode: EMPIRE){
name
}
jediHero:hero(eposode:JEDI){
name
}
}

fragments

reusable units called fragments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

1
2
3
4
5
6
7
8
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

1
2
3
4
5
6
7
8
query Hero($episode: Episode, $withFriends: hero(episode: $episode){
hero(episode: $episode){
name
friends @include(if:$withFriends){
name
}
}
})

Schemas and Types

Validation

Execution

Introspection

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×