#AppSync

2026-01-06

[Tech Hướng Dẫn] Tạo API GraphQL không máy chủ với AWS AppSync, Lambda & DynamoDB.

AppSync như bồi bàn nhận request GraphQL
Lambda là "nhà bếp" xử lý logic
DynamoDB là kho lưu trữ dữ liệu

Chức năng chính:
• Tạo todo mới
• Lấy todo bằng ID
• Liệt kê toàn bộ todo

Lợi ích:
🗸 Hoàn toàn serverless - AWS tự động scale
🗸 Chỉ trả phí khi sử dụng
🗸 Kiến trúc rõ ràng, dễ bảo trì

Ứng dụng cho:
📱 Backend mobile/web
⚡ Ứng dụng real-time
🌐 Kiến trúc microservice

#KhongMayChu #GraphQL #AWS #AppSync #

2025-12-18

AppSync subscriptions: waiting for start_ack can still result in missing events

It seems like that when AppSync returns a `start_ack` message in response to a subscription `start` it won't necessarily mean that all future events will be delivered.

Subscriptions are the mechanism to deliver real-time events from AppSync. It is based on WebSockets and its protocol is documented [here](docs.aws.amazon.com/appsync/la).

In the protocol, a client needs to send a `start` message with the GraphQL query to start receiving updates. Then AppSync responds with a `start_ack` if everything is OK and then sends `data` events whenever an update happens.

Reading the documentation my impression was that `start_ack` is the moment when the subscription is live and all future events will be delivered. But what I'm seeing is that **it's not the case**. Even when the event is strictly triggered after the `start_ack` is received sometimes it is not delivered to the client.

Why is it a problem?

A common pattern for APIs with real-time updates is to subscribe to updates first then query the current state. This way there is no "temporal dead zone" when updates are lost. But that requires a definitive *point in time* when the subscription is live. Without that, it's only best-effort and messages will be lost every now and then especially in cases when the subscription is made just before the event, common in tests and some async workflows.

Real-time updates, especially in AppSync, is a complex topic and it's easy to get wrong. I've [written about it before](advancedweb.hu/shorts/apollos-), it has a [separate section in my book](graphql-on-aws-appsync-book.co), and I even [made a library](github.com/sashee/appsync-subs) because I wasn't particularly happy with the AWS-provided one.

I noticed tests using subscriptions timeouting for a long time now, but i wrote it off as "something complex is happening" and added some retries to handle it. A message is published to IoT Core that triggers a Lambda, that writes to DynamoDB then it triggers the subscription. A lot can go wrong so it's realistic that the 10-ish seconds sometimes pass.

But I then started working on a simpler setup and still noticed that some events seemingly never arrive. This time I could pinpoint the issue because if a parallel subscription is opened before then the event is delivered there. So the problem must be that the subscription is not live even though AppSync says it is.

Hopefully, it will get fixed soon.

Bug report opened [in the AppSync repo](github.com/aws/aws-appsync-com).

#aws #appsync

Originally published [on my blog](advancedweb.hu/shorts/appsync-)

:rss: Qiita - 人気の記事qiita@rss-mstdn.studiofreesia.com
2025-07-18

AppSync Event API を使用したリアルタイム文字起こしをブラウザに表示させてみた!
qiita.com/hirota_kodai/items/9

#qiita #lambda #Kinesis #AmazonConnect #AppSync

2025-03-26

GraphQL tip: Have the subscription types contain all filterable fields on the top-level.

For example, a Todo event that should allow filtering by user, group, severity, and id, should have these as well as the item itself:

```graphql
type TodoEvent {
userId: ID!
groupId: ID!
todoId: ID!
severity: Severity!
todo: Todo
}
```

Originally, it was the only way for filtering in AppSync, but that changed when it [started supporting filters on nested fields](docs.aws.amazon.com/appsync/la). So, why it's still a best practice?

The primary reason is deletion: this structure makes it easy to support sending an event when the item is deleted and all the filters will work.

Then an additional benefit is when there is a filter that is not present in the entity itself. For example, if a Todo item's `userId` can be changed it is useful to notify the original owner. In that case, a `prevUserId` field can be added to the subscription allowing users to subscribe to events when an item is removed from them.

#graphql #tips #appsync

Originally published [on my blog](advancedweb.hu/shorts/graphql-)

2025-03-07

GraphQL tip: Only make fields required if they are present for all users

In GraphQL it's possible to mark a field as required with the `!`. For example, a `User` always have a `Project` according to this schema:

```graphql
type User {
name: String!
email: String!
project: Project!
}
```

Marking fields required is a powerful tool in the GraphQL toolbox as clients won't need handle the case when the field is null. But it can also lead to a cascading null effect.

For example, let's say the Project has a `client` field that also can't be null:

```graphql
type User {
name: String!
email: String!
project: Project!
tickets: [Ticket!]!
}

type Project {
name: String!
description: String!
client: String!
}

// + Ticket
```

Let's say the `Project.client` is considered sensitive information and will be removed for non-admin users.

Then a query that gets the `User`, its `Project`, and and then the `client` field will fail to return any data:

```graphql
query {
user(id: "user1") {
name
email
project {
name
description
client
}
tickets: {
id
}
}
}
```

The result:

```json
{
"data": null,
"errors": ...
}
```

Because of this, be mindful which fields you mark as required. If a field can be null for some users during normal operations, such as when you have different access levels, it should be optional. A field should be marked as mandatory only when it returns a value in every case.

#appsync #graphql

Originally published [on my blog](advancedweb.hu/shorts/graphql-)

2025-02-18

AppSync footgun: util.error does not work if called with non-string arguments

The `util.error` function terminates the current resolver with the error provided in the argument, similar to how an exception would work. Its signature is:

```
util.error(String, String?, Object?, Object?)
```

But what happens when the provided arguments don't match this signature?

Consider this code:

```js
if (ctx.result.statusCode < 200 || ctx.result.statusCode >= 300) {
util.error(ctx.result.statusCode);
}
return JSON.parse(ctx.result.body);
```

The expectation here is that if the `statusCode` is outside the 2xx range then it will result in an error.

But what happens instead is that the `util.error` is silently ignored. There is no error, no warning, it behaves as it was never called.

All these lines are no-ops:

```js
util.error(25);
util.error(true);
util.error("abc", 25);
```

Issue opened at [github.com/aws/aws-appsync-com.

#aws #appsync

Originally published [on my blog](advancedweb.hu/shorts/appsync-)

Mark Powell, formerly of NASADrmarkpowell@iosdev.space
2024-11-22

In case anyone is interested, after discussing the AWS product roadmap with them, it is clear that DataStore is on the way out. Recommend that no one use it for any new development and anyone currently using it begin making plans to rearchitect. #Amplify #AppSync

There does not seem to be any first party offline-first for mobile data sync service in AWS anymore. Looking into third party services next.

Mark Powell, formerly of NASADrmarkpowell@iosdev.space
2024-11-20

Anyone used #Amplify #AppSync with DataStore in their iOS app? I’d love to ask a few noob questions if you wouldn’t mind.

2024-11-06

New AWS::AppSync::ChannelNamespace

Use the AWS::AppSync::ChannelNamespace resource to creates a channel namespace associated with an Api.
docs.aws.amazon.com/AWSCloudFo #appsync #cloudformation

2024-11-06

New AWS::AppSync::Api

Use the AWS::AppSync::Api resource to create an AWS AppSync API that you can use for an AWS AppSync API with your preferred configuration,.
docs.aws.amazon.com/AWSCloudFo #appsync #cloudformation

Connel Hooleyconnel
2024-09-29

to with JS resolvers seems like a really nice idea but I just keep hitting walls with it.

Connel Hooleyconnel
2024-09-29

The main problem I'm working through is my primary key can change, so I'm trying to make sure I can still update it in the future by having a static guid as an attribute in the tables.

I'm amazed there's no nice way for to query a table with multiple IDs. The get batch item support isn't great as it requires the table name to be hard coded in the resolved, which you can't do if you want dev and prod envs.

2024-09-12

I have an #AppSync API that I use to put and store user generated data that is authenticated using #Cognito. As part of the JWT payload there is a device ID that is unique to the signed in user on that device.

Jessica :verified:jessicamauerhan@phpc.social
2024-06-14

If anyone out there has created a GraphQL API using AWS AppSync with multiple services and implemented the root "node" field as defined in the spec, I could really use some help.

I cannot figure out how to direct AppSync to the right lambda resolver for the actual type. I tried a pipeline resolver, but that only works when the type is resolved by the last function in the pipeline - if it's an earlier service, the returned value gets lost.

#graphql #aws #appsync

Please boost for reach! 🙇‍♀️

2024-01-22

#AWS just revealed that Amazon EventBridge Event Bus supports AWS AppSync as an Event Bus's target.

Developers can now stream real-time updates like sports scores from their apps to frontend applications, whether on mobile or desktop: bit.ly/3HtzZo0

#InfoQ #EventBridge #AppSync #CloudComputing #EventDrivenArchitecture

2023-08-22

Issue #244 of Off-by-none is out! This week, #AppSync kills VTL, @HashiCorp makes a bunch of friends, and #serverless opinions get summarized. Plus, we recognize Hiroko Nishimura as our ⭐️ of the week! #offbynone offbynone.io/issues/244/

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst