@@ -4,7 +4,6 @@ import { tables } from '@architect/sandbox'
44import { subscribe } from './subscribe'
55import { mockServerContext } from '../test/mockServer'
66import { connection_init } from './connection_init'
7- import { equals } from '@aws/dynamodb-expressions'
87import { collect } from 'streaming-iterables'
98import { subscribe as pubsubSubscribe } from '../pubsub/subscribe'
109import { makeExecutableSchema } from '@graphql-tools/schema'
@@ -60,8 +59,14 @@ describe('messages/subscribe', () => {
6059 ] ,
6160 delete : [ ] ,
6261 } )
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' } )
6570 } )
6671
6772 it ( 'sends errors on error' , async ( ) => {
@@ -158,7 +163,12 @@ describe('messages/subscribe', () => {
158163 assert . equal ( error . message , 'don\'t subscribe!' )
159164 }
160165 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+ } ) )
162172 assert . isEmpty ( subscriptions )
163173 } )
164174
@@ -206,7 +216,12 @@ describe('messages/subscribe', () => {
206216 await connection_init ( { server, event : connectionInitEvent , message : JSON . parse ( connectionInitEvent . body ) } )
207217 await subscribe ( { server, event, message : JSON . parse ( event . body ) } )
208218 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+ } ) )
210225 assert . isNotEmpty ( subscriptions )
211226 } )
212227 } )
0 commit comments