Skip to content

Commit 8b24dd8

Browse files
committed
fix: removed old cli method from Flutter path
1 parent 963e56d commit 8b24dd8

File tree

6 files changed

+59
-43
lines changed

6 files changed

+59
-43
lines changed

src/fragments/guides/api-graphql/android/subscriptions-by-id.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Now you can create a custom subscription for comment creation with a specific post id:
1+
import all0 from "/src/fragments/guides/api-graphql/common/subscriptions-by-id.mdx";
2+
3+
<Fragments fragments={{all: all0}} />
24

35
<BlockSwitcher>
46
<Block name="Java">
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
By default, subscriptions will be created for the following mutations:
2+
3+
```graphql
4+
# Post type
5+
onCreatePost
6+
onUpdatePost
7+
onDeletePost
8+
9+
# Comment type
10+
onCreateComment
11+
onUpdateComment
12+
onDeleteComment
13+
```
14+
15+
One operation that is not covered is if you wanted to only subscribe to comments for a specific post.
16+
17+
Because the schema has a one to many relationship enabled between posts and comments, you can use the auto-generated field `postCommentsId` that defines the relationship between the post and the comment to set this up in a new Subscription definition.
18+
19+
To implement this, you could update the schema with the following:
20+
21+
```graphql
22+
type Post @model {
23+
id: ID!
24+
title: String!
25+
content: String
26+
comments: [Comment] @hasMany
27+
}
28+
29+
type Comment @model {
30+
id: ID!
31+
content: String
32+
postCommentsId: ID!
33+
}
34+
35+
type Subscription {
36+
onCommentByPostId(postCommentsId: ID!): Comment
37+
@aws_subscribe(mutations: ["createComment"])
38+
}
39+
40+
```
41+
42+
Now you can create a custom subscription for comment creation with a specific post id:

src/fragments/guides/api-graphql/flutter/subscriptions-by-id.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
Now you can create a custom subscription for comment creation with a specific post id:
2-
31
<BlockSwitcher>
42

53
<Block name="Stable (Mobile)">
64

5+
import all0 from "/src/fragments/guides/api-graphql/common/subscriptions-by-id.mdx";
6+
7+
<Fragments fragments={{all: all0}} />
8+
79
```dart
810
Future<void> subscribeByPostId(String postId) async {
911
const graphQLDocument = r'''
@@ -37,6 +39,8 @@ Future<void> subscribeByPostId(String postId) async {
3739

3840
<Block name="Developer Preview (Mobile, Web & Desktop)">
3941

42+
You can subscribe to only comments for a specific post with the following:
43+
4044
```dart
4145
Future<void> subscribeByPostId(String postId) async {
4246
final subscriptionRequest = ModelSubscriptions.onCreate(

src/fragments/guides/api-graphql/ios/subscriptions-by-id.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Now you can create a custom subscription for comment creation with a specific post id:
1+
import all0 from "/src/fragments/guides/api-graphql/common/subscriptions-by-id.mdx";
2+
3+
<Fragments fragments={{all: all0}} />
4+
25

36
```swift
47
extension GraphQLRequest {

src/fragments/guides/api-graphql/js/subscriptions-by-id.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import all0 from "/src/fragments/guides/api-graphql/common/subscriptions-by-id.mdx";
2+
3+
<Fragments fragments={{all: all0}} />
4+
15
```js
26
import { API } from 'aws-amplify';
37
import { onCommentByPostId } from './graphql/subscriptions';

src/pages/guides/api-graphql/subscriptions-by-id/q/platform/[platform].mdx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,7 @@ type Comment @model {
2323
}
2424
```
2525

26-
By default, subscriptions will be created for the following mutations:
2726

28-
```graphql
29-
# Post type
30-
onCreatePost
31-
onUpdatePost
32-
onDeletePost
33-
34-
# Comment type
35-
onCreateComment
36-
onUpdateComment
37-
onDeleteComment
38-
```
39-
40-
One operation that is not covered is if you wanted to only subscribe to comments for a specific post.
41-
42-
Because the schema has a one to many relationship enabled between posts and comments, you can use the auto-generated field `postCommentsId` that defines the relationship between the post and the comment to set this up in a new Subscription definition.
43-
44-
To implement this, you could update the schema with the following:
45-
46-
```graphql
47-
type Post @model {
48-
id: ID!
49-
title: String!
50-
content: String
51-
comments: [Comment] @hasMany
52-
}
53-
54-
type Comment @model {
55-
id: ID!
56-
content: String
57-
postCommentsId: ID!
58-
}
59-
60-
type Subscription {
61-
onCommentByPostId(postCommentsId: ID!): Comment
62-
@aws_subscribe(mutations: ["createComment"])
63-
}
64-
65-
```
6627

6728
import ios0 from "/src/fragments/guides/api-graphql/ios/subscriptions-by-id.mdx";
6829

0 commit comments

Comments
 (0)