aws-appsync

Custom filtering on subscription in AWS AppSync

◇◆丶佛笑我妖孽 提交于 2019-12-10 12:32:19
问题 Is it possible to have custom filtering logic on subscription in AWS AppSync? As I know, current behavior is: e.g. my schema is like the following type Mutation { createEvent(userId: ID!, event: Event!): Event! } type Subscription { onEvent(userId: ID!): Event! @aws_subscribe(mutations: ["createEvent"]) } Current behavior of AppSync is, when I trigger createEvent, AppSync promise that the subscriber of Subscription receive the Event if the userId are equal. i.e. the filtering logic of AppSync

Group authorization in AppSync using IAM authentication

*爱你&永不变心* 提交于 2019-12-09 17:51:48
问题 My service requires user groups for authorising access to data. Group authorization examples in AppSync documentation are based on User Pool claims. I'm using IAM authentication so $context.identity doesn't include claims or any similar information. See, for example, topic "Use Case: Group Can Create New Record" in: https://docs.aws.amazon.com/appsync/latest/devguide/security-authorization-use-cases.html #set($expression = "") #set($expressionValues = {}) #foreach($group in $context.identity

How return JSON object from DynamoDB with appsync?

萝らか妹 提交于 2019-12-09 01:05:20
问题 How I can get JSON object in response from DynamoDB ? I store data in DB as array of object in format JSON. I have next mapping template request { "version": "2017-02-28", "operation": "PutItem", "key": { "userId": { "S": "$context.identity.username" } }, #set( $attrs = $util.dynamodb.toMapValues($ctx.args)) #set( $attrs.categories = $util.dynamodb.toDynamoDB($ctx.args.categories)) "attributeValues": $util.toJson($attrs) } and mapping template response #set( $result = $ctx.result) #set(

Apollo mutate calling update four times for a single mutation

蓝咒 提交于 2019-12-08 19:12:28
Every time I add a new item in my app, the mutation calls update() four times, for some reason. The first two are optimistic data, and in the second batch, one is optimistic and one is real data from the network. I can't make any sense of this. The new item being created shows up twice on the page. This is my mutation: mutation CreateTrack($name: String!, $trackNum: Int, $s3Key: String!) { createTrack(name: $name, trackNum: $trackNum, s3Key: $s3Key) { trackId name createdAt duration trackNum s3Key isProcessing didProcessingFail } } And this is the mutation code: createTrack({ name, s3Key }) {

How to PUT / UPDATE nested data with GraphQL?

岁酱吖の 提交于 2019-12-08 13:33:33
I'm attempting my first GraphQL backend using AWS AppSync. I'm simply trying to figure out how to use one-to-many associations. I expect to receive the many related objects as a list of children, and to be able to write some of these children when creating a new user. type User { id: ID! name: String! records: [Records!]! } type Records { id: ID! userId: ID! title: String! ... etc ... } Using the AppSync interface, I click on Create Resources once to make a Records table and again to make a Users table, both in DynamoDB. This also automatically adds mutations, subscriptions, input types, and

How to send custom error in AppSync with $util.error

非 Y 不嫁゛ 提交于 2019-12-08 07:37:33
问题 I have a question about AppSync error handling. I would like to send errorInfo object along with the error response and I tried with $util.error . Per the document: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html $util.error(String, String, Object, Object) Throws a custom error. This can be used in request or response mapping templates if the template detects an error with the request or with the invocation result. Additionally, an errorType field, a data

AppSync query resolver: are expressionNames and expressionValues necessary?

ε祈祈猫儿з 提交于 2019-12-08 06:30:06
问题 https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html#aws-appsync-resolver-mapping-template-reference-dynamodb-query AppSync doc says that expressionNames and expressionValues are optional fields, but they are always populated by code generation. First question, should they be included as a best practice when working with DynamoDB? If so, why? AppSync resolver for a query on the partition key: { "version": "2017-02-28", "operation": "Query",

How to PUT / UPDATE nested data with GraphQL?

北城余情 提交于 2019-12-08 06:01:47
问题 I'm attempting my first GraphQL backend using AWS AppSync. I'm simply trying to figure out how to use one-to-many associations. I expect to receive the many related objects as a list of children, and to be able to write some of these children when creating a new user. type User { id: ID! name: String! records: [Records!]! } type Records { id: ID! userId: ID! title: String! ... etc ... } Using the AppSync interface, I click on Create Resources once to make a Records table and again to make a

Reactjs/Apollo/AppSync Mutation triggered twice

懵懂的女人 提交于 2019-12-08 05:57:36
问题 I'm having an issue with React/Apollo/AppSync with mutations triggering twice (or more). I have a React app that has an update mutation triggered by the usual UI button onClick. <button className={`btn btn-sm`} onClick={(event) => { that.toggleSubscription(event, subscriptionid, serviceid, status); }}> <i className={`fas ${icon} fa-fw`} /> {title} </button> The toggleSubscription function looks like this: toggleSubscription = async (event, subscriptionid, serviceid, currentStatus) => { event

AWS Amplify Graphql query on @connection

爷,独闯天下 提交于 2019-12-08 05:09:56
问题 I am using AWS Amplify (with Cli and Angular 7 for front end) for Graphql/AppSync and wondering how to get all connected items when it exceeds 10 items? Let's say I have created a schema.graphql like this: type User @model { id: ID! firstname: String lastname: String project: Project @connection(name: "ProjectUsers") } type Project @model { id: ID! title: String task: String members: [User] @connection(name: "ProjectUsers") } When running amplify push it generates queries and mutations. When