一张参考图

说明

从上图我们可以方便的看出schmea 能做的事情

  • Generate a GraphQL equivalent of your schema to control your GraphQL API.(生成 graphql api)
  • Control permissions for accessing and modifying data.(访问控制)
  • Generate forms on the client.(client 以及表单生成)
  • Validate form contents on submission.(数据校验)
  • Auto-generate paginated, searchable datatables.(自动生成分页,查询)
  • Auto-generate smart cards for displaying individual documents.(智能卡生成)
  • Add callbacks on document insert or edit.(数据添加,编辑时候的回掉)

参考例子

  • schema

    类似graphql-yogo 以及graphql-js 的schema 定义

  1. const schema = {
  2. // default properties
  3. _id: {
  4. type: String,
  5. optional: true,
  6. canRead: ["guests"]
  7. },
  8. createdAt: {
  9. type: Date,
  10. optional: true,
  11. canRead: ["guests"],
  12. onCreate: ({ newDocument, currentUser }) => {
  13. return new Date();
  14. }
  15. },
  16. userId: {
  17. type: String,
  18. optional: true,
  19. canRead: ["guests"],
  20. resolveAs: {
  21. fieldName: "user",
  22. type: "User",
  23. resolver: (movie, args, context) => {
  24. return context.Users.findOne(
  25. { _id: movie.userId },
  26. {
  27. fields: context.Users.getViewableFields(
  28. context.currentUser,
  29. context.Users
  30. )
  31. }
  32. );
  33. },
  34. addOriginalField: true
  35. }
  36. },
  37. // custom properties
  38. name: {
  39. label: "Name",
  40. type: String,
  41. optional: true,
  42. canRead: ["guests"],
  43. canCreate: ["members"],
  44. canUpdate: ["members"]
  45. },
  46. year: {
  47. label: "Year",
  48. type: String,
  49. optional: true,
  50. canRead: ["guests"],
  51. canCreate: ["members"],
  52. canUpdate: ["members"]
  53. },
  54. review: {
  55. label: "Review",
  56. type: String,
  57. optional: true,
  58. control: "textarea",
  59. canRead: ["guests"],
  60. canCreate: ["members"],
  61. canUpdate: ["members"]
  62. }
  63. };
  • 创建collection

    实际上上就是graphql api schema 定义以及解析处理

  1. const Movies = createCollection({
  2. typeName: "Movie",
  3. schema,
  4. resolvers,
  5. mutations
  6. });

参考资料

http://docs.vulcanjs.org/schemas.html

 
 
 
 

vulcanjs schemas&& collections的更多相关文章

  1. Java基础Map接口+Collections工具类

    1.Map中我们主要讲两个接口 HashMap  与   LinkedHashMap (1)其中LinkedHashMap是有序的  怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...

  2. Java基础Map接口+Collections

    1.Map中我们主要讲两个接口 HashMap  与   LinkedHashMap (1)其中LinkedHashMap是有序的  怎么存怎么取出来 我们讲一下Map的增删改查功能: /* * Ma ...

  3. 计算机程序的思维逻辑 (54) - 剖析Collections - 设计模式

    上节我们提到,类Collections中大概有两类功能,第一类是对容器接口对象进行操作,第二类是返回一个容器接口对象,上节我们介绍了第一类,本节我们介绍第二类. 第二类方法大概可以分为两组: 接受其他 ...

  4. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  5. 计算机程序的思维逻辑 (53) - 剖析Collections - 算法

    之前几节介绍了各种具体容器类和抽象容器类,上节我们提到,Java中有一个类Collections,提供了很多针对容器接口的通用功能,这些功能都是以静态方法的方式提供的. 都有哪些功能呢?大概可以分为两 ...

  6. Collection和Collections的区别?

    Collection 是接口(Interface),是集合类的上层接口. Collections是类(Class),集合操作的工具类,服务于Collection框架.它是一个算法类,提供一系列静态方法 ...

  7. Collections.shuffle

    1.Collections.shuffler 最近有个需求是生成十万级至百万级的所有随机数,最简单的思路是一个个生成,生成新的时候排重,但是这样时间复杂度是o(n^2),网上看了几个博客的解决方法都不 ...

  8. 集合工具类:collections

    collection与collections的关系? public class Collectionsextends Object collection与collections没有直接的关系,但是与集 ...

  9. Map集合及与Collection的区别、HashMap和HashTable的区别、Collections、

    特点:将键映射到值的对象,一个映射不能包含重复的键,每个键最多只能映射到一个值. Map集合和Collection集合的区别 Map集合:成对出现 (情侣)                       ...

随机推荐

  1. 3.5 MIPS体系结构

    计算机组成 3 指令系统体系结构 3.5 MIPS体系结构 MIPS是精简指令系统的代表,采用了与X86相反的设计理念,并引领了精简指令系统的潮流,那就让我们一起来看一看这究竟是怎么一回事. 要探讨M ...

  2. java克隆机制

    看了下面博客就很明白了 http://www.cnblogs.com/Qian123/p/5710533.html#_label0 java对象创建方式有三种: 1.通过new对象 2.通过java克 ...

  3. 1月11日Atom 插件安装。

    查看已安装的Atom插件(前提:已经安装Atom) 打开终端 输入apm ls命令,回车. 未安装任何插件时,显示如下 Built-in Atom packages (89) ...此处省略... / ...

  4. exec可以用来执行语句的

    set @sql='select * from '+@table print @sql exec(@sql)

  5. page上BeanId与ActionType中的ParameterId

    今天遇到一件有意思的异常. 一个基于EO的VO在页面加载进来之后就CreateRow了一行数据,主键HeaderId也相应的插入了值,但是在保存的时候,老是报HeaderId不能为空的异常. 经查,页 ...

  6. en_e out1

      1◆e i: ə ɜː e i   2◆ eu 3◆ ew 4◆ ei ey eu ew 5◆ eer ue   6◆ ee u: u   7◆ er ɜː     8◆ ere ie ue   ...

  7. poj2895

    题解: splay,维护当前第k大 并查集维护当前集合 合并x,y时,del(num[x]),del(num[y]),insert(num[x]+num[y]) 代码: #include<cst ...

  8. 关于apicloud ios自定义模块引用第三方framework not found for architecture armv7

    1 .自定义模块 新建模块必须是静态库 2.使用的第三方framework 必须要把 .h文件开放出来 3.编译要用 真机模式 (上传模块以后,自定义load要编译,用生成的二维码调试) 4. 添加监 ...

  9. python安装大型包时出现错误Unable to find vcvarsall.bat

    在windows平台上,据说是安装cpython编写的包时会出现Unable to find vcvarsall.bat这种错误,缺失编译C的环境或组件吧,所以这个包就安装不成功,这个时候简单的方法就 ...

  10. hdu 1556 Color the ball (线段树+代码详解)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...