@@ -4,7 +4,6 @@ import { tables } from '@architect/sandbox'
4
4
import { subscribe } from './subscribe'
5
5
import { mockServerContext } from '../test/mockServer'
6
6
import { connection_init } from './connection_init'
7
- import { equals } from '@aws/dynamodb-expressions'
8
7
import { collect } from 'streaming-iterables'
9
8
import { subscribe as pubsubSubscribe } from '../pubsub/subscribe'
10
9
import { makeExecutableSchema } from '@graphql-tools/schema'
@@ -60,8 +59,14 @@ describe('messages/subscribe', () => {
60
59
] ,
61
60
delete : [ ] ,
62
61
} )
63
- const [ subscriptions ] = await collect ( server . mapper . query ( server . model . Subscription , { connectionId : equals ( event . requestContext . connectionId ) } , { indexName : 'ConnectionIndex' } ) )
64
- assert . include ( subscriptions , { connectionId, subscriptionId : '1234' } )
62
+
63
+ const [ subscriptions ] = await collect ( server . models . subscription . query ( {
64
+ IndexName : 'ConnectionIndex' ,
65
+ ExpressionAttributeNames : { '#a' : 'connectionId' } ,
66
+ ExpressionAttributeValues : { ':1' : event . requestContext . connectionId } ,
67
+ KeyConditionExpression : '#a = :1' ,
68
+ } ) )
69
+ assert . containSubset ( subscriptions , { connectionId, subscriptionId : '1234' } )
65
70
} )
66
71
67
72
it ( 'sends errors on error' , async ( ) => {
@@ -158,7 +163,12 @@ describe('messages/subscribe', () => {
158
163
assert . equal ( error . message , 'don\'t subscribe!' )
159
164
}
160
165
assert . deepEqual ( onSubscribe , [ 'We did it!' ] )
161
- const subscriptions = await collect ( server . mapper . query ( server . model . Subscription , { connectionId : equals ( event . requestContext . connectionId ) } , { indexName : 'ConnectionIndex' } ) )
166
+ const subscriptions = await collect ( server . models . subscription . query ( {
167
+ IndexName : 'ConnectionIndex' ,
168
+ ExpressionAttributeNames : { '#a' : 'connectionId' } ,
169
+ ExpressionAttributeValues : { ':1' : event . requestContext . connectionId } ,
170
+ KeyConditionExpression : '#a = :1' ,
171
+ } ) )
162
172
assert . isEmpty ( subscriptions )
163
173
} )
164
174
@@ -206,7 +216,12 @@ describe('messages/subscribe', () => {
206
216
await connection_init ( { server, event : connectionInitEvent , message : JSON . parse ( connectionInitEvent . body ) } )
207
217
await subscribe ( { server, event, message : JSON . parse ( event . body ) } )
208
218
assert . deepEqual ( events , [ 'onSubscribe' , 'onAfterSubscribe' ] )
209
- const subscriptions = await collect ( server . mapper . query ( server . model . Subscription , { connectionId : equals ( event . requestContext . connectionId ) } , { indexName : 'ConnectionIndex' } ) )
219
+ const subscriptions = await collect ( server . models . subscription . query ( {
220
+ IndexName : 'ConnectionIndex' ,
221
+ ExpressionAttributeNames : { '#a' : 'connectionId' } ,
222
+ ExpressionAttributeValues : { ':1' : event . requestContext . connectionId } ,
223
+ KeyConditionExpression : '#a = :1' ,
224
+ } ) )
210
225
assert . isNotEmpty ( subscriptions )
211
226
} )
212
227
} )
0 commit comments