博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[GraphQL] Query GraphQL Interface Types in GraphQL Playground
阅读量:4983 次
发布时间:2019-06-12

本文共 1154 字,大约阅读时间需要 3 分钟。

Interfaces are similar to Unions in that they provide a mechanism for dealing with different types of data. However, an interface is more suited for data types that include many of the same fields. In this lesson, we will query different types of pets.

To follow along with these queries, go to the .

 

Interface:

 

# Write your query or mutation herequery {  totalPets,  availablePets,  checkedOutPets,  allAvailablePets {    __typename,    ...PetDetail,    # only related to CAT    ... on Cat {      sleepAmount    },    # only related to Rabbit    ... on Rabbit {      favoriteFood,      floppy    },    # only related to Stingray    ... on  Stingray {      fast    }  }}fragment PetDetail on Pet {  name,  weight,  status,  photo {    thumb  }}

 

Data return:

{  "data": {    "totalPets": 25,    "availablePets": 23,    "checkedOutPets": 2,    "allAvailablePets": [      {        "__typename": "Cat",        "name": "Biscuit",        "weight": 10.2,        "status": null,        "photo": {          "thumb": "https://www.catis.life/placeholder/200"        },        "sleepAmount": 21      },     ...}

 

转载于:https://www.cnblogs.com/Answer1215/p/11384598.html

你可能感兴趣的文章
HDU6203 ping ping ping
查看>>
Fireworks基本使用
查看>>
Java基础常见英语词汇
查看>>
UINavigationController的视图层理关系
查看>>
POJ 1308 Is It A Tree?(并查集)
查看>>
N进制到M进制的转换问题
查看>>
php PDO (转载)
查看>>
[置顶] 一名优秀的程序设计师是如何管理知识的?
查看>>
highcharts曲线图
查看>>
extjs动态改变样式
查看>>
宏定义
查看>>
笔记:git基本操作
查看>>
【MemSQL Start[c]UP 3.0 - Round 1 C】 Pie Rules
查看>>
Ognl中“%”、“#”、“$”详解
查看>>
我对应用软件——美团的看法
查看>>
python第六篇文件处理类型
查看>>
向量非零元素个数_向量范数详解+代码实现
查看>>
LeetCode 题解之Add Digits
查看>>
hdu1502 , Regular Words, dp,高精度加法
查看>>
iOS 电话在后台运行时,我的启动图片被压缩
查看>>