博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AWS AppSync 的基本语句
阅读量:4954 次
发布时间:2019-06-12

本文共 2239 字,大约阅读时间需要 7 分钟。

type Event {    id: ID!    name: String    where: String    when: String    description: String    # Paginate through all comments belonging to an individual post.    comments(limit: Int, nextToken: String): CommentConnection}

 AWS AppSync 是API的一种新标准;Schema是它的核心,SDL是Schema的主要语言。

 

schema {    query: Query    mutation: Mutation    subscription: Subscription}

 

 

 

  1. query 查询语句:
type Query {    # Get a single event by id.    getEvent(id: ID!): Event    # Paginate through events.    listEvents(filter: TableEventFilterInput, limit: Int, nextToken: String): EventConnection}

例子:

query{  getEvent(id: "c16701cb-d614-4f21-b733-a636bc1c8437" ){    description    name  }}

 

返回 json:

{  "data": {    "getEvent": {      "description": "test",      "name": "landen"    }  }}

  2. mutation 

type Mutation {    # Create a single event.    createEvent(        name: String!,        when: String!,        where: String!,        description: String!    ): Event    # Delete a single event by id.    deleteEvent(id: ID!): Event    # Comment on an event.    commentOnEvent(eventId: ID!, content: String!, createdAt: String!): Comment}

 

    • createEvent 添加事件    

        

mutation{  createEvent(    name: "landen",    when: "2018-08-18",    where: "guangdong",    description: "today is rainny"  ){    id    name  }}

返回 json:

{  "data": {    "getEvent": {      "description": "test",      "name": "landen"    }  }}
    •  commentOnEvent 更改事件:   
mutation{  commentOnEvent(    eventId: "c16701cb-d614-4f21-b733-a636bc1c8437",    content: "comment : rainny",    createdAt: "today"  ){    eventId  }}

返回 json:

{  "data": {    "commentOnEvent": {      "eventId": "c16701cb-d614-4f21-b733-a636bc1c8437"    }  }}

 

    • deleteEvent 删除事件:
mutation{  deleteEvent(id: "c16701cb-d614-4f21-b733-a636bc1c8437"){    name     description  }}

返回 json:

{  "data": {    "deleteEvent": {      "name": "landen",      "description": "test"    }  }}

 

  3.  subscription 订阅事件:

type Subscription {    subscribeToEventComments(eventId: String!): Comment        @aws_subscribe(mutations: ["commentOnEvent"])}
subscription{  subscribeToEventComments(eventId:"b5a25e27-8416-4486-8df1-27c185520074"){    content    @aws_subscribe(  mutations:["commentOnEvent"])  }  }

 

转载于:https://www.cnblogs.com/landen/p/9497825.html

你可能感兴趣的文章
REST构架风格介绍:状态表述转移
查看>>
c++ operator
查看>>
java小技巧
查看>>
POJ 3204 Ikki's Story I - Road Reconstruction
查看>>
网页消息类
查看>>
【BZOJ】2959: 长跑(lct+缩点)(暂时弃坑)
查看>>
日常一些出现bug的问题
查看>>
同时启动多个tomcat服务器
查看>>
怎么将iphone上的照片导出到本地文件
查看>>
Repeater+DataPagerSource分页
查看>>
模块化导出
查看>>
pagebean pagetag java 后台代码实现分页 demo 前台标签分页 后台java分页
查看>>
Sphinx 2.0.8 发布,全文搜索引擎 Installing Sphinx on Windows
查看>>
pod
查看>>
iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
查看>>
LUOGU P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat…
查看>>
toad for oracle中文显示乱码
查看>>
SQL中Group By的使用
查看>>
错误org/aopalliance/intercept/MethodInterceptor解决方法
查看>>
Pylint在项目中的使用
查看>>