In order to handle collections of items in a GraphQL Schema, GraphQL has a List Type. In this video, we’ll learn the syntax for specifying a List of items in a GraphQL Schema.

Quey list of videos:

const { graphql, buildSchema } = require('graphql');

const schema = buildSchema(`
type Video {
id: ID,
title: String,
duration: Int,
watched: Boolean
} type Query {
video: Video,
videos: [Video]
} type Schema{
query: Query
}
`); const videos = [
{
id : '',
title : 'react',
duration : ,
watched : true
},
{
id : '',
title : 'relay',
duration : ,
watched : false
}
]; const resolvers = {
video : () => ({
id : '',
title : 'bar',
duration : ,
watched : true
}),
videos: () => videos
}; const query = `
query myFirstQuery {
videos {
id,
title,
duration,
watched
}
}
`; graphql(schema, query, resolvers)
.then((result) => console.log(JSON.stringify(result, null, )))
.catch(console.error)

[GraphQL] Use GraphQL's List Type for Collections的更多相关文章

  1. Unity3d:Unknown type 'System.Collections.Generic.CollectionDebuggerView'1

    问题描述:如图,在调试状态下说:Unknown type 'System.Collections.Generic.CollectionDebuggerView'1<ignore_js_op> ...

  2. Web api help page error CS0012: Type "System.Collections.Generic.Dictionary'2错误

    1.在asp.net Boilerplate项目中,Abp.0.12.0.2,.net framework4.5.2.下载后添加了webApi的helpPage功能,调试出现错误. dubug : a ...

  3. [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 ...

  4. [GraphQL] Create an Input Object Type for Complex Mutations

    When we have certain mutations that require more complex input parameters, we can leverage the Input ...

  5. GraphQL ---02 GraphQL和C#结合的实战项目

    本文章是介绍和记录如何创建GraphQL项目,以及如何使用GraphQL进行数据的相关操作.项目参照GraphQL .Net 的官方文档进行实践 一.项目结构: 为了更好的和原有的项目结合在一起,尽可 ...

  6. 让ASP.NET Core支持GraphQL之-GraphQL的实现原理

    众所周知RESTful API是目前最流行的软件架构风格之一,它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制. RESTful的优越性是毋庸置疑 ...

  7. [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 ...

  8. [GraphQL] Reuse GraphQL Selection Sets with Fragments

    Fragments are selection sets that can be used across multiple queries. They allow you to refactor re ...

  9. 序列化时提示There was an error reflecting type 'System.Collections.Generic.List`1

    序列化xml文件到List中,非win10下出现了这个错误,但是在win10下正常.经过仔细的研究,发现是序列化工具类不能使用Static.去掉Static即可.

随机推荐

  1. PHP微信墙制作,开源

    PHP微信墙制作 微信墙 PHP 注意:由于微信官网不定时会更新,其中模拟登陆以及爬取数据的方式可能会失效,最近这12个月里,就有两次更新导致此功能需要重写. 服务端源码->github地址传送 ...

  2. SQL Server 重新初始化系统数据库中的单引号问题

    在最近的数据库跨机房迁移中,由于硬件的限制,需要滚动式地将数据库一台台迁移到新机房,先在新机房搭建一个新环境,将数据迁移过去,再将旧机房的机器下架搬到新机房,重新配置后用于下一轮的升级,重新配置过程中 ...

  3. Configuring Locales

    原文地址:http://people.debian.org/~schultmc/locales.html The Easy Way Install debconf (i.e. runapt-get u ...

  4. memcached(二)事件模型源码分析

    memcachedd事件模型 在memcachedd中,作者为了专注于缓存的设计,使用了libevent来开发事件模型.memcachedd的时间模型同nginx的类似,拥有一个主进行(master) ...

  5. HBase在单Column和多Column情况下批量Put的性能对比分析

    作者: 大圆那些事 | 文章可以转载,请以超链接形式标明文章原始出处和作者信息 网址: http://www.cnblogs.com/panfeng412/archive/2013/11/28/hba ...

  6. ASP.NET 5系列教程(七)完结篇-解读代码

    在本文中,我们将一起查看TodoController 类代码. [Route] 属性定义了Controller的URL 模板: [Route("api/[controller]") ...

  7. 【设计模式】Java版设计模式的类图汇总

    Abstract Factory Intent: Provide an interface for creating families of related or dependent objects ...

  8. beego中orm关联查询使用解析

    这两天在学习beego框架,之前学习的时候遗漏了很多东西,比如orm.缓存.应用监控.模板处理等,这里将通过实例记录下如何使用beego自带的orm进行关联查询操作. 首先说明下,beego的orm有 ...

  9. XCode自动打ipa包脚本 命令

    XCode 新建文件 选择other Shell script  放入下面命令行. #工程绝对路径 #cd $ project_path=$(pwd) #build文件夹路径 build_path=$ ...

  10. (转载)新手如何正确理解GitHub中“PR(pull request)”中的意思

    我从知乎看到的两个答案,分别从实际意义以及语言学角度告诉你改怎么理解PR,很简洁,这个理解非常棒,会解决新手刚看到PR(pull request)这个词时的困惑.   实际意义:   有一个仓库,叫R ...