【发布时间】:2019-12-11 11:19:44
【问题描述】:
我有下面的 graphl api 查询,我使用它从反应前端应用程序发送数据和对象以获得所需的结果
{
allSectionRequests(data:{
requestStageName:"Request Submitted"
}){
section
type
}
}
然后我尝试从下面的反应中传递变量
export const GET_SECTIONREQUESTS = gql`
query AllSectionRequests($data: sectionRequestParamsInput){
allSectionRequests(data: $data){
section
type
}
}
`;
我已经附上了我需要发送到下面的graphql api的图像
下面是我将在组件内调用查询然后将data对象传递给graphql api的反应代码
const { data: dashBoardData, loading: dashBoardDataLoading, error: dashBoardDataError } = useQuery(GET_SECTIONREQUESTS, {
variables: { data: { requestStageName: 'Request Submitted' } },
});
我在下面遇到这样的错误
The variable **data** type is not compatible with the type of the argument **data**.
↵Expected type: SectionRequestParamsInput.
我不确定这段代码哪里做错了,谁能帮忙解决这个问题。
非常感谢
【问题讨论】:
-
SectionRequestParamsInput是什么? -
graphql api 期望的输入对象
-
在您的查询中
sectionRequestParamsInput以小写s开头;大写有帮助吗?
标签: javascript reactjs graphql react-apollo apollo-client