'React GraphQLError: Syntax Error: Expected Name, found $
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
