【发布时间】:2019-01-09 21:20:08
【问题描述】:
我正在我的前端创建一个购物车,我想将购物车中的所有项目作为一个数组传递给我后端的突变 addLicense,因此我不必进行多次 API 调用。这可能吗?如果是这样,怎么做,或者我有什么选择?
我尝试在这样的参数周围添加方括号
extend type Mutation {
addLicense([
licenseType: String!
licenseAmount: String!
isActive: Boolean
expirationDate: Date!
]): License!
}
我也尝试将对象类型设置为参数
extend type Mutation {
addLicense(
license: [License]
): License!
第一次尝试抛出此错误
/app/node_modules/graphql/language/parser.js:1463
throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
^
GraphQLError: Syntax Error: Expected Name, found [
at syntaxError
(/app/node_modules/graphql/error/syntaxError.js:24:10)
其他尝试抛出此错误
Error: The type of Mutation.addLicense(license:) must be Input Type but got: [License].
【问题讨论】:
标签: javascript graphql apollo