[GraphQL] Query GraphQL Interface Types in GraphQL Playground
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 Pet Library GraphQL Playground.
Interface:

# Write your query or mutation here
query {
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": ,
"availablePets": ,
"checkedOutPets": ,
"allAvailablePets": [
{
"__typename": "Cat",
"name": "Biscuit",
"weight": 10.2,
"status": null,
"photo": {
"thumb": "https://www.catis.life/placeholder/200"
},
"sleepAmount":
},
...
}
[GraphQL] Query GraphQL Interface Types in GraphQL Playground的更多相关文章
- [GraphQL] Add an Interface to a GraphQL Schema
As we start building out more complex GraphQL schemas, certain fields start to repeat across differe ...
- 爬取LeetCode题目——如何发送GraphQL Query获取数据
前言 GraphQL 是一种用于 API 的查询语言,是由 Facebook 开源的一种用于提供数据查询服务的抽象框架.在服务端 API 开发中,很多时候定义一个接口返回的数据相对固定,因此要获得 ...
- SpringBoot开发秘籍 - 集成Graphql Query
概述 REST作为一种现代网络应用非常流行的软件架构风格受到广大WEB开发者的喜爱,在目前软件架构设计模式中随处可见REST的身影,但是随着REST的流行与发展,它的一个最大的缺点开始暴露出来: 在很 ...
- Go语言规格说明书 之 接口类型(Interface types)
go version go1.11 windows/amd64 本文为阅读Go语言中文官网的规则说明书(https://golang.google.cn/ref/spec)而做的笔记,介绍Go语言的 ...
- [GraphQL] Query Lists of Multiple Types using a Union in GraphQL
Unions are used when we want a GraphQL field or list to handle multiple types of data. With a Union ...
- [GraphQL] Use Arguments in a GraphQL Query
In GraphQL, every field and nested object is able to take in arguments of varying types in order to ...
- [GraphQL] Query a GraphQL API with graphql-request
To query a GraphQL API, all you need to do is send an HTTP request that includes the query operation ...
- [GraphQL] Query Local and Remote Data in Apollo Link State
In this lesson, you will learn how to query local and remote data in Apollo Link State in the same c ...
- [GraphQL] Mutations and Input Types
Sometimes, you want to resues object type when doing mutation, you can use 'input' type to help: inp ...
随机推荐
- 转:Cesium 和 Webpack
原文地址:https://www.jianshu.com/p/85917bcc023f 注意:webpack 和 webpack-cli 的安装参考 https://www.cnblogs.com/m ...
- linux--Linux 各目录及每个目录的详细介绍
2017年08月31日 17:53:38 worthsen 阅读数 3490更多 所属专栏: Linux 版权声明:本文为博主原创文章,如要转载,请注明地址,谢谢^...^ https://blo ...
- springboot2.x日志配置记录
springboot日志管理: springboot2.x默认使用commons-logging作为内部日志的输出,日志的实现可以选择Java Util Logging,Log4J2和logback如 ...
- Springmvc在项目启动时查询数据库并初始化静态变量
private static List<ResourceEntity> resourceList = null; //初始化的全局静态变量 @Autowired private Resou ...
- 20191106-基于Python的对字母基数排序
基数排序 概念 基数排序的算法过程是先将待排元素补位,使其长度一致,然后按照序列中的元素的每个位数进行分桶的一种算法. 比如待排序列是数字,则将所有待比较数值(正整数)统一为同样的数位长度,数位较短的 ...
- PAT(B) 1063 计算谱半径(Java)
题目链接:1063 计算谱半径 (20 point(s)) 题目描述 在数学中,矩阵的"谱半径"是指其特征值的模集合的上确界.换言之,对于给定的 n 个复数空间的特征值 { a1 ...
- SAS学习笔记55 RTF输出标题级别的设置
很多人都喜欢将表格的标题通过report中的compute before _page_ 添加到table的前面,但是这种方式并不能直接定义标题的级别,需要后期进行表格的加工. 在使用proc repo ...
- Thymeleaf模板引擎与springboot关联后,在html中无法使用el表达式获取model存的值
头部引入了thymeleaf <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thy ...
- restTemplate源码解析(目录)
restTemplate是spring实现的,基于restful风格的http请求模板.使用restTemplate可以简化请求操作的复杂性,同时规范了代码风格.本系列文章,将根据以下目录顺序,从源码 ...
- element-ui 省市区联动组件 el-cascader
<el-form-item label="省市 :" prop="description"> <el-cascader size=" ...