Skip to content

Commit

Permalink
Fix publish multiple events
Browse files Browse the repository at this point in the history
  • Loading branch information
zxl629 committed Feb 12, 2025
1 parent a29d4a1 commit 29583bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
import { DEFAULT_KEEP_ALIVE_TIMEOUT, MESSAGE_TYPES } from '../constants';
import { AWSWebSocketProvider } from '../AWSWebSocketProvider';
import { awsRealTimeHeaderBasedAuth } from '../AWSWebSocketProvider/authHeaders';
import { serializeEvents } from '../../internals/events/utils';

// resolved/actual AuthMode values. identityPool gets resolves to IAM upstream in InternalGraphQLAPI._graphqlSubscribe
type ResolvedGraphQLAuthModes = Exclude<GraphQLAuthMode, 'identityPool'>;
Expand Down Expand Up @@ -103,7 +104,7 @@ export class AWSAppSyncEventProvider extends AWSWebSocketProvider {
// This will be needed for WS publish
const data = {
channel: query,
events: [variables],
events: variables,
};

const serializedData = JSON.stringify(data);
Expand All @@ -127,7 +128,7 @@ export class AWSAppSyncEventProvider extends AWSWebSocketProvider {
const subscriptionMessage = {
id: subscriptionId,
channel: query,
events: [JSON.stringify(variables)],
events: variables !== undefined ? serializeEvents(variables) : undefined,
authorization: {
...headers,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/src/internals/events/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const configure = () => {
};

/**
* Event API expects and array of JSON strings
* Event API expects an array of JSON strings
*
* @param events - JSON-serializable value or an array of values
* @returns array of JSON strings
Expand Down

0 comments on commit 29583bc

Please sign in to comment.