-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Argument of type 'this' is not assignable to parameter of type 'Stack'. #13164
Comments
Hey @Tswalano, thank you for reaching out. Thank you for pointing the documentation, we will work on updating the example.
Amplify custom currently does support AWS CDK v2, please refer to the document providing information on the migration: https://docs.amplify.aws/cli/migration/aws-cdk-migration/ |
This seems to fix the issue thank you... While i still have you here can we also use APPSYNC_JS to write the resolvers in the Amplify Custom CDK instead of using VTL templating? |
@Tswalano glad to hear that you were able to mitigate the issue.
Yes, we can write a custom resource that creates JS resolvers similar to the example. For example: Schema input AMPLIFY {
globalAuthRule: AuthRule = { allow: public }
} # FOR TESTING ONLY!
type Todo @model {
id: ID!
name: String!
description: String
}
type Query {
querySomething(id: String!, name: String): Todo
} Custom resource: const requestJS = `
import { util } from '@aws-appsync/utils'
export function request(ctx) {
return {
operation: 'GetItem',
key: util.dynamodb.toMapValues({ id: ctx.args.id }),
}
}
export function response(ctx) {
return ctx.result
}
`;
// unit resolver
const resolver = new appsync.CfnResolver(this, "custom-resolver", {
apiId: cdk.Fn.ref(retVal.api.<app-name>.GraphQLAPIIdOutput),
fieldName: "querySomething",
typeName: "Query",
dataSourceName: "TodoTable", // DataSource name
runtime: {
name: "APPSYNC_JS",
runtimeVersion: "1.0.0",
},
code: requestJS,
}); I would suggest testing this in a test/dev environments for any unexpected behaviours. |
Awesome.. Thanks :) |
|
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v18.16.1
Amplify CLI Version
12.1.1
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Describe the bug
Following this documentation without touching anything, the code throws:
Argument of type 'this' is not assignable to parameter of type 'Stack'. Property 'toYamlString' is missing in type 'cdkStack' but required in type 'Stack'.ts(2345) stack.d.ts(328, 5): 'toYamlString' is declared here.
The docs are out of date and still using the CDK v1 (or is this on purpose? Does amplify custom support the cdk v2? running
amplify push
results in:Put your logs below this line
The text was updated successfully, but these errors were encountered: