Mike McCall
04/01/2021, 4:59 AMJay
Mike McCall
04/01/2021, 1:32 PMMike McCall
04/01/2021, 1:33 PMconst api = new appSync.GraphqlApi(this, 'Api', {name: "api"})
new cdk.CfnOutput(this, "GraphqlUrl", {
value: api.graphqlUrl
});
Mike McCall
04/01/2021, 1:39 PMJay
IGraphqlApi
doesn't support the graphqlUrl
property https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-appsync.IGraphqlApi.html. I'm not sure if that's the same error you are getting.Jay
Jay
Mike McCall
04/01/2021, 1:42 PMMike McCall
04/01/2021, 2:13 PMJay
Frank
AppSyncApi
can also take an existing appsync.GraphqlApi
. ie.
new AppSyncApi(this, "GraphqlApi", {
graphqlApi: appsync.GraphqlApi.fromGraphqlApiAttributes(this, "IGraphqlApi", {
graphqlApiId,
}),
resolvers: {
"Query listNotes": "src/list.main",
"Mutation createNote": "src/create.main",
},
});
Mike McCall
04/01/2021, 5:07 PMFrank
appsync.GraphqlApi.fromGraphqlApiAttributes
returns an IGraphqlApi
type.Mike McCall
04/01/2021, 5:08 PMMike McCall
04/01/2021, 5:12 PMnew CfnOutput(this, 'AppSyncUrl', { value: this.appSyncApi.graphqlUrl })
for example this fails.Frank
sst.AppSyncApi
is creating an appsync.GraphqlApi
and you will get a GraphqlApi
type back
• when ppl are importing, the imported api is of type appsync.IGraphqlApi
and you will get a IGraphqlApi
type back
Hence we are always casting the property to IGraphqlApi
Frank
Frank
(this.appSyncApi as appsync.GraphqlApi).graphqlUrl
• we change the construct such that this.appSyncApi
is only set when ppl are not importing, and it will be of type appsync.GraphqlApi
. This way we don’t need to accomodate for the imported case.Frank
Mike McCall
04/01/2021, 5:19 PMFrank
Frank
Mike McCall
04/01/2021, 5:24 PMFrank