【发布时间】:2019-06-12 23:21:12
【问题描述】:
graphql的服务端是nodejs和express。这是 graphql 的架构。它有一个查询,它接受具有 from 和 to 日期的 DateT 对象。
var schema = buildSchema(`
type Query {
courseWithDate(
timeFilter: DateT
): Course
},
type Course {
...
from: String
to: String
},
type DateT{
from : String
to : String
}
`);
这就是我获得课程的方式
我可以使用这个 url 运行应用程序
localhost:4000/graphql
这是我正在使用的查询
query courseWithDate($from: dateFrom, $to: dateTo) {
courseWithDate(timeFilter: {
from: "${dateFrom}"
to: "${dateTo}"
}) {
title
...
}
}
使用这些参数
{
"from": "2019-10-10","to":"2019-10-10"
}
我收到的异常消息与我尝试传递的输入类型有关。
{
"errors": [
{
"message": "The type of Query.courseWithDate(timeFilter:) must be Input Type but got: DateT.",
"locations": [
{
"line": 6,
"column": 25
}
]
}
]
}
【问题讨论】: