React GraphQLerror:语法错误:预期名称,找到$
我一直在研究Apollo grapghql,并在一个方案中累积了一个我必须将变量传递到查询的情况,但是当我尝试这样做时,我
GraphQLError: Syntax Error: Expected Name, found $
错误
let getFilters=
{
userPoliciesGet($filter: PolicyFilter) {
policiesExternal {
${this.requestsPayload}
}
policiesImported {
${this.requestsPayload}
}
}
}
`
遇到
import apollo from './client'
apollo.query({
query: gql`
${getFilters}
`,
variables: {
filter: { status: 'ENDED' }
},
fetchPolicy: 'no-cache'
})
会 正确并为其余的API工作。
我不明白这种方式有什么问题, 如果我尝试在没有任何变量的情况下击中此API,则可以正常工作,但是当我使用过滤器变量击中它时,它不行。
I have been working on Apollo Grapghql and come accross a scenario where i had to pass a variable to the query but I am getting an error when i try to do so
GraphQLError: Syntax Error: Expected Name, found $
Here is my query
let getFilters=
{
userPoliciesGet($filter: PolicyFilter) {
policiesExternal {
${this.requestsPayload}
}
policiesImported {
${this.requestsPayload}
}
}
}
`
and then i am calling this query like
import apollo from './client'
apollo.query({
query: gql`
${getFilters}
`,
variables: {
filter: { status: 'ENDED' }
},
fetchPolicy: 'no-cache'
})
The ApolloClient is configured correct and works for the rest of the api's.
I dont understand what is wrong with this way, if i try to hit this api without any variables, it works fine ,but not when i hit it with the filter varibles
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论