Getting @aws_subscribe to work with CDK aws-appsync
0
For the application I'm building Amplify is an overkill. I've been able to manage to build graphQL with appsync and cdk only at this point. Now, I'm running into issue with @aws_subscribe -- it just does not work for me. I'm wondering if the directives like this require Amplify to be aded and initialized? Is there any way to initialize and process graphQL subscriptions with CDK api directly?
My schema.graphql contains certain definitions:
type Message{
chatUuid: String!
uuid: String!
messageUuid: String!
text: String!
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
sendMessage(
chatUuid: String!
uuid: String!
messageUuid: String!
text: String!
): Message
}
type Subscription {
onSendMessage(chatUuid: String!): Message
@aws_subscribe(mutations: ["sendMessage"])
}
And here is how I'm initializing my graphQL with CDK off of that definition file:
const api = new appsync.GraphqlApi(this, `${deployEnv()}-WiSaw-appsyncApi-cdk`,
{
name: `${deployEnv()}-cdk-wisaw-appsync-api`,
schema: appsync.Schema.fromAsset('graphql/schema.graphql'),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.API_KEY,
apiKeyConfig: {
expires: cdk.Expiration.after(cdk.Duration.days(365)),
},
},
},
})
For debugging purposes, tried to attach a resolver to the subscription:
export default async function main(
event:any
) {
console.log({event,})
return {}
}
In the log see the following:
{
event: {
arguments: {},
identity: null,
source: null,
request: { headers: [Object], domainName: null },
prev: null,
info: {
selectionSetList: [Array],
selectionSetGraphQL: '{\n chatUuid\n createdAt\n messageUuid\n text\n updatedAt\n uuid\n}',
fieldName: 'onSendMessage',
parentTypeName: 'Subscription',
variables: {}
},
stash: {}
}
}
At this point, I'm running out of things to try. Any help or direction would be highly appreciated.
asked 5 months ago9 views
1 Answers
Relevant questions
Amplify export infrastructures does not work with CDK V2
asked a month agoIAM Permission Boundary does not prevent CDK escalating privilege access?
Accepted Answerasked 3 days ago[Launch Announcement] AWS AppSync adds support for enhanced filtering in real-time GraphQL subscriptions
asked a month agoCDK DMS replication instance
Accepted Answerasked 2 years agoValue 'debug GraphQL source'
asked 2 years agoOAuth Scope based Authorization in AppSync
asked 4 months agoBuild an IOS Application Tutorial - Trigger Authentication at Run Time
asked 4 months agoAllow AWS Amplify access a restricted site for npm builds
asked 2 months agoIs AthenaDynamoDBConnector available for CDK
asked 2 months agoGetting @aws_subscribe to work with CDK aws-appsync
asked 5 months ago
I know this is definately possible. Am trying to recreate your example but it contains some typos.