Typescript aws cdk appsync架构创建状态失败,详细信息为:保存架构时内部失败
给定以下graphql模式Typescript aws cdk appsync架构创建状态失败,详细信息为:保存架构时内部失败,typescript,aws-lambda,graphql,aws-appsync,aws-cdk,Typescript,Aws Lambda,Graphql,Aws Appsync,Aws Cdk,给定以下graphql模式 # graphql/schema.graphql type AppUser { userId: String fullName: String } type Query { getUser(userId: String): AppUser getUsers(): [AppUser] } type Mutation { addUser(user: AppUser!): AppUser } 以及在lib/mystack.ts中定义的以下cdk代码
# graphql/schema.graphql
type AppUser {
userId: String
fullName: String
}
type Query {
getUser(userId: String): AppUser
getUsers(): [AppUser]
}
type Mutation {
addUser(user: AppUser!): AppUser
}
以及在lib/mystack.ts中定义的以下cdk代码:
const graphql=new appsync.GraphQLApi(这是“GraphQLApi”{
名称:“metrolens graphql api”,
日志配置:{
fieldLogLevel:appsync.fieldLogLevel.ALL,
},
授权配置:{
默认授权:{
//用户池,
defaultAction:appsync.UserPoolDefaultAction.ALLOW,
},
//additionalAuthorizationModes:[{apiKeyDesc:'My API Key'}],
},
schemaDefinitionFile:props?.schemaDirectory,
})
const lambdaRegister=new nodejs.nodejs函数(此“寄存器”{
functionName:'寄存器',
运行时:lambda.runtime.NODEJS_12_X,
超时:cdk.持续时间.秒(10),
条目:'./lambda/register/register-0.ts',
处理程序:“处理程序”,
图层:[图层],
描述:“注册用户”,
})
const lambdaLogin=new nodejs.nodejs函数(此“登录”{
functionName:'登录',
运行时:lambda.runtime.NODEJS_12_X,
超时:cdk.持续时间.秒(10),
条目:'./lambda/login/login-0.ts',
处理程序:“处理程序”,
图层:[图层],
描述:“登录用户”,
})
常量lambdargisterDataSource=graphql.addlambdatasource(
“羔羊登记员”,
'注册由appsync触发的lambda',
羔羊登记员
)
lambdaRegisterDataSource.createResolver({
typeName:'突变',
字段名:“addUser”,
requestMappingTemplate:appsync.MappingTemplate.lambdaRequest(),
responseMappingTemplate:appsync.MappingTemplate.lambdaResult(),
})
常量lambdalogindasource=graphql.addlambdatasource(
“lambdaLogin”,
'由appsync触发的登录lambda',
lambdaLogin
)
lambdalogindasource.createResolver({
typeName:'查询',
fieldName:'getUsers',
requestMappingTemplate:appsync.MappingTemplate.lambdaRequest(),
responseMappingTemplate:appsync.MappingTemplate.lambdaResult(),
})
在部署阶段,我收到以下错误消息:
GraphQLApi/Schema(GraphQLApiSchema5937B126)架构创建状态失败,详细信息为:保存架构时内部失败
以前有人遇到过这个错误吗?我怀疑我的graphql模式有问题,但我不知道它是什么。另一个答案提到,即使不使用DynamoDB,DynamoDB的保留字也可能导致冲突,因此我将User
类型重命名为AppSync
。然而,看起来Query
也是一个保留字,但据我所知,这也是graphql定义所必需的。请帮忙。AWS CDK很糟糕。更新getUsers():[AppUser]
到getUsers:[AppUser]
我遇到了同样的错误,并通过将模式插入验证器找到了它
输入你的一个给
{
"error": "Syntax error while parsing GraphQL query. Invalid input \"{\\n getUser(userId: String): AppUser\\n getUsers()\", expected ImplementsInterfaces, Directives, FieldDefinition or Comments (line 6, column 12):\ntype Query {\n ^"
}
更新getUsers():[AppUser]
至getUsers:[AppUser]
我遇到了同样的错误,并通过将模式插入验证器找到了它
输入你的一个给
{
"error": "Syntax error while parsing GraphQL query. Invalid input \"{\\n getUser(userId: String): AppUser\\n getUsers()\", expected ImplementsInterfaces, Directives, FieldDefinition or Comments (line 6, column 12):\ntype Query {\n ^"
}
问题是我的模式不正确
AppUser
是一种类型,但我将其用作addUser
变异的输入。使用特殊的input
关键字定义查询和突变的输入。我最终复制了AppUser
成为:
input AppUserInput {
userId: String
fullName: String
}
这就解决了问题。问题是我的模式不正确
AppUser
是一种类型,但我将其用作addUser
变异的输入。使用特殊的input
关键字定义查询和突变的输入。我最终复制了AppUser
成为:
input AppUserInput {
userId: String
fullName: String
}
这就解决了问题。谢谢,帮了我很多忙。该错误不是真正的描述性错误。添加注释-使用控制台中的AppSync架构编辑器-我有相同的错误-结果表明AppSync无法识别大多数验证器允许的三引号注释。谢谢,帮了我大忙。这个错误不是真正的描述性错误。添加一个注释-使用控制台中的AppSync架构编辑器-我有相同的错误-结果表明AppSync无法识别大多数验证器允许的三引号注释。