[英]Reuse @model types in Amplify
there那里
Lets say I have a clean angular amplify project with one defined @model
called TodoItem
.假设我有一个干净的 angular 放大项目,其中定义了一个名为
@model
的TodoItem
。 Now I want to override the default create mutation with my custom created lambda (using @function
directive).现在我想用我自定义创建的 lambda(使用
@function
指令)覆盖默认创建突变。 But I would like to reuse the default input CreateTodoItemInput
that was generated for default.但我想重用为默认生成的默认输入
CreateTodoItemInput
。 If i reference CreateTodoItemInput
in schema.graphql
i'm getting error during amplify push
that there is no defined input with this name如果我在
schema.graphql
中引用CreateTodoItemInput
,我在amplify push
期间遇到错误,即没有使用此名称定义的输入
Is there a way to reuse it or in such a case I need to create an identical duplicate input type?有没有办法重用它,或者在这种情况下我需要创建一个相同的重复输入类型?
If you're using typescript, Amplify will generate a file that has types and enums matching your schema.如果您使用的是 typescript,Amplify 将生成一个文件,其类型和枚举与您的架构匹配。
They stick it in the front-end: src/API.ts
, but you can reference it in your backend.他们将其粘贴在前端:
src/API.ts
,但您可以在后端引用它。
Not sure if it's relevant (I stumble my way through the stupid build tools);不确定它是否相关(我在愚蠢的构建工具中跌跌撞撞); but my Lambda's tsconfig.js looks like this:
但是我的 Lambda 的 tsconfig.js 看起来像这样:
{
"extends": "../../../../../tsconfig.json",
"compilerOptions": {
"lib": [
"es2020"
],
"noEmit": true,
"target": "es2020"
},
"include": [
"./"
]
}
Inside my Lambda, I just grab a type when I need it:在我的 Lambda 中,我只是在需要时抓取一个类型:
import { OrderStatus, TriggerType } from 'API'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.