flipboard.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Welcome to Flipboard on Mastodon. A place for our community of curators and enthusiasts to inform and inspire each other. If you'd like to join please request an invitation via the sign-up page.

Administered by:

Server stats:

1.2K
active users

#graphql

1 post1 participant0 posts today

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-)

docs.aws.amazon.comDefining enhanced subscriptions filters in AWS AppSync - AWS AppSync GraphQLLearn about enhanced subscription filtering in AWS AppSync.

6 years ago, #GitLab decided that they want to switch from REST to #GraphQL (corresponding epic: gitlab.com/groups/gitlab-org/-, initial discussion took place 8 years ago: gitlab.com/gitlab-org/gitlab-f).

They are not done yet and still introduce bugs and performance issues because of that migration (recent example: gitlab.com/gitlab-org/gitlab/-).

I am not saying that GraphQL is bad in general but I have some doubts that this was a good decision.

GitLabGraphQL everywhere (#1366) · Epics · Epics · GitLab.org · GitLabWe want to get to a point where we use our GraphQL API for as much development as possible. This gives us a number of advantages: