鉴于此模式:
input TodoInput {
id: String
title: String
}
input SaveInput {
nodes: [TodoInput]
}
type SavePayload {
message: String!
}
type Mutation {
save(input: SaveInput): SavePayload
}
type TodoInput = {
id: string | null,
title: string
}
type SaveInput = {
nodes: TodoInput[];
}
type SavePayload = {
message: string;
}
export const resolver = {
save: (input: SaveInput): SavePayload => {
input.nodes.forEach(todo => api.saveTodo(todo as Todo));
return { message : 'success' };
}
}
当我发送此请求时:
mutation {
save(input: {
nodes: [
{id: "1", title: "Todo 1"}
]
}) {
message
}
}
input.nodes
是
undefined
在服务器端。
有人知道我做错了什么吗?
有用信息:
-
-
我使用的是typescript、express和express graphql。