File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
1
coverage :
2
- branch : main
2
+ branch : v1
3
3
status :
4
4
project :
5
5
default :
Original file line number Diff line number Diff line change @@ -161,6 +161,45 @@ class GraphQLSubscriptionTests: XCTestCase {
161
161
XCTAssertNil ( document. variables)
162
162
}
163
163
164
+ /// - Given: a `Model` type Comment
165
+ /// - When:
166
+ /// - the model has nested association
167
+ /// - the subscription is of type `.onCreate`
168
+ /// - Then:
169
+ /// - check if the generated GraphQL document is a valid subscription
170
+ /// - the nested field contain only required fields
171
+ func testOnCreateGraphQLSubscriptionWithPrimaryKeyOnly( ) {
172
+
173
+ var documentBuilder = ModelBasedGraphQLDocumentBuilder ( modelSchema: Comment . schema,
174
+ operationType: . subscription,
175
+ primaryKeysOnly: true )
176
+ documentBuilder. add ( decorator: DirectiveNameDecorator ( type: . onCreate) )
177
+ documentBuilder. add ( decorator: ConflictResolutionDecorator ( graphQLType: . subscription,
178
+ primaryKeysOnly: true ) )
179
+ let document = documentBuilder. build ( )
180
+ let expectedQueryDocument = """
181
+ subscription OnCreateComment {
182
+ onCreateComment {
183
+ id
184
+ content
185
+ createdAt
186
+ post {
187
+ id
188
+ __typename
189
+ _deleted
190
+ }
191
+ __typename
192
+ _version
193
+ _deleted
194
+ _lastChangedAt
195
+ }
196
+ }
197
+ """
198
+ XCTAssertEqual ( document. name, " onCreateComment " )
199
+ XCTAssertEqual ( document. stringValue, expectedQueryDocument)
200
+ XCTAssertNil ( document. variables)
201
+ }
202
+
164
203
/// - Given: a `Model` type
165
204
/// - When:
166
205
/// - the model has no eager loaded associations
You can’t perform that action at this time.
0 commit comments