Python_05_Flask / Code /GraphQL /09_query.graphql
zxy0307's picture
Upload 181 files
1b5b024 verified
Raw History Blame Contribute Delete
1.14 kB
#1. select * from table id = ""
{
human(id:"1002"){
id
name
friends {
id
}
appearsIn
}
}
#2. select * from table t1 left join table t2 on t1.id = t2.friends_id
{
human(id:"1002"){
id
name
friends {
id
name
}
appearsIn
}
}
#3. 别名的使用
{
h1:human(id:"1002"){
id
name
homePlanet
}
h2:human(id:"1003"){
id
name
homePlanet
}
}
#4. 字段的复用
{
h1:human(id:"1002"){
...hf
}
h2:human(id:"1003"){
...hf
}
}
fragment hf on Human{
id
name
homePlanet
}
#5. 获取接口特有数据
{
hero(episode:EMPIRE){
id
name
friends {
id
}
appearsIn
...on Droid{
primaryFunction
}
...on Human{
homePlanet
}
}
}
# 给查询定义名称
query q1 {
hero(episode:EMPIRE){
id
name
friends {
id
}
appearsIn
...on Droid{
primaryFunction
}
...on Human{
homePlanet
}
}
}
# 动态传递参数
query queryC($id:Episode){
hero(episode:$id){
name
appearsIn
}
}
{"episode":"JEDI"} #传递进去的参数