[GraphQL] Reuse GraphQL Selection Sets with Fragments
Fragments are selection sets that can be used across multiple queries. They allow you to refactor redundant selection sets, and they are essential when querying unions or interface types. In this lesson, we will improve our query logic by creating a fragment for the activity selection set.
To follow along with these queries, go to the Pet Library GraphQL Playground.
query Pet {
petById(id:"S-2") {
name,
weight,
photo {
thumb
},
status,
inCareOf {
name
}
}
allPets(category:RABBIT){
name,
weight,
photo {
thumb
},
status,
inCareOf {
name,
username
}
}
}
We can reuse part of query with fragement:
query Pet {
petById(id:"S-2") {
...PetDetail,
inCareOf {
...CustomerDetail
}
}
allPets(category:RABBIT){
...PetDetail,
inCareOf {
...CustomerDetail
}
}
}
fragment CustomerDetail on Customer {
name,
username
}
fragment PetDetail on Pet {
name,
weight,
photo {
thumb
},
status,
}
[GraphQL] Reuse GraphQL Selection Sets with Fragments的更多相关文章
- [GraphQL] Use GraphQL's List Type for Collections
In order to handle collections of items in a GraphQL Schema, GraphQL has a List Type. In this video, ...
- [GraphQL] Reuse Query Fields with GraphQL Fragments
A GraphQL fragment encapsulates a collection of fields that can be included in queries. In this vide ...
- 让ASP.NET Core支持GraphQL之-GraphQL的实现原理
众所周知RESTful API是目前最流行的软件架构风格之一,它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制. RESTful的优越性是毋庸置疑 ...
- [GraphQL] Use GraphQL's Object Type for Basic Types
We can create the most basic components of our GraphQL Schema using GraphQL's Object Types. These ty ...
- GraphQL ---02 GraphQL和C#结合的实战项目
本文章是介绍和记录如何创建GraphQL项目,以及如何使用GraphQL进行数据的相关操作.项目参照GraphQL .Net 的官方文档进行实践 一.项目结构: 为了更好的和原有的项目结合在一起,尽可 ...
- [GraphQL] Query GraphQL Interface Types in GraphQL Playground
Interfaces are similar to Unions in that they provide a mechanism for dealing with different types o ...
- graphql 新API 开发方式
我们知道 GraphQL 使用 Schema 来描述数据,并通过制定和实现 GraphQL 规范 定义了支持 Schema 查询的 DSQL (Domain Specific Query Langua ...
- [转] Initial Impressions on GraphQL & Relay
https://kadira.io/blog/graphql/initial-impression-on-relay-and-graphql http://graphql.org/blog/subsc ...
- 转 How do GraphQL remote schemas work
文章转自 prisma 官方博客,写的很不错 In this article, we want to understand how we can use any existing GraphQL AP ...
随机推荐
- mysql创建唯一索引UNIQUE INDEX,以及报错“#失败原因: [Execute: Duplicate entry '733186700' for key 'uniq_video_id_index']”
要给t_video_prods表的video_id字段创建唯一所以,可以使用下面这条语句: alter table t_video_prods add UNIQUE INDEX `uniq_video ...
- PB笔记之数据窗口行不能编辑的原因
这里不打勾就不能编辑行
- websocket 协议简述
WebSocket 是一种网络通信协议,RFC 6455 定义了它的通信标准,属于服务器推送技术的一种 由于 HTTP 无状态.无连接.单向通信的特性,导致 HTTP 协议无法实现服务器主动向客户端发 ...
- linux命令行删除N天前的数据的命令
命令: find . -mtime +N -type f -name "*.log.*" -exec rm -f {} \; 简单解释: find .查询 ; -mtime 规 ...
- Jquery中.bind()、.live()、.delegate()和.on()之间的区别详解(转)
转自:https://www.jb51.net/article/120018.htm
- hdu 1501 贪心问题
这道题目的关键就是逐个搜索的过程 找个时间得复习一下dfs了 这里使用temp作为参照变量 每次比较以后(由于已经排序好) 已temp为参照进行下一次的比较
- C# 、子窗体调用父窗体属性、方法
namespace Test { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } p ...
- springboot_4 spring boot 使用servlet,filter,listener和interceptor
上一篇我们学习了 spring boot 利用Controller响应数据与响应页面. 一般的Web开发使用 Controller 基本上可以完成大部分需求,但是有的时候我们还是会用到 Servlet ...
- java 爬虫:开源java爬虫 swing工具 Imgraber
1实现点: 1.返回给定URL网页内,所有图像url list 2.返回给定URL网页内,自动生成图像文件路径.txt 文件 3.返回给定URL网页内,下载txt文件指定的图片url,并将所有图像保存 ...
- python day2:python的基本数据类型及其方法
目录 python day2 1. 编码转换 2. python的基本数据类型 3. for 迭代遍历 4. 列表list 5. 元组tuple 6. 字典dict 7. 枚举enumerate 8. ...