[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 ...
随机推荐
- ant 节点和属性
任务和javac命令是相似,它编译两种类型的java文件1)没有被编译的java文件2)曾经编译过,但是class文件版本和当前对应的java文件版本不匹配的java文件. 1)javac命令支持的参 ...
- Java基础---Java 数组
数组概念: 数组就是存储数据长度固定的容器,保证多个数据的数据类型要一致. 数组的定义 格式:数组定义格式详解: 数组存储的数据类型: 创建的数组容器可以存储什么数据类型. [] : 表示数组. 数组 ...
- 剑指offer61:序列化二叉树
1 题目描述 请实现两个函数,分别用来序列化和反序列化二叉树 二叉树的序列化是指:把一棵二叉树按照某种遍历方式的结果以某种格式保存为字符串,从而使得内存中建立起来的二叉树可以持久保存.序列化可以基于先 ...
- PHP中的PDO数据对象
PDO: PHP Data Object:php的数据对象.pdo是数据库操作工具类!1,它能操作很多种数据库,比如mysql,oracle,sybase....2,它具有操作数据库的更多的功能,比如 ...
- 微软商店一直安装不上Intel Media SDK DFP
具体表现为一直安装失败,但是下载进度条一直在,无法去除. 此方法来自 https://answers.microsoft.com/en-us/windows/forum/all/error-code- ...
- Asp.Net Core 使用 MediatR
Asp.Net Core 使用 MediatR 项目中使用了CQRS读写分离,增删改 的地方使用了 MediatR ,将进程内消息的发送和处理进行解耦.于是便有了这篇文章,整理并记录一下自己的学习.遇 ...
- .net mvc 迁移到 .netcore
迁移的时候发现,ef6 不能添加 到 .NET Standard2 的类库,因为不兼容, 6 以上的版本只能用于 .net 4.5 以上 只能用别的
- Centos6 r8192ce_pci
Centos6 r8192ce_pci # # yum install epel-release# yum-config-manager --enable rhui-REGION-rhel-serve ...
- Eva 剧情解析
Eva 剧情解析 来源 https://zhuanlan.zhihu.com/p/20864898 [0.写在前面的话] 相信和我年龄差不多的小伙伴们对<新世纪福音战士>( <Neo ...
- metasploit情报收集
1.msf连接数据库 service postgresql start(postgresql默认用户名scott,密码tiger) msf > db_connect 用户名:密码@127.0.0 ...