I'm using angular-apollo lib to call backend graphql. I want to reuse my queries generated by gql
function. It means I need to use variables
, but when I write query like this:
this.apollo.watchQuery<MyQuery>({
query: gql`
{
bar(id: $foo) {
id
}
`,
variables: {
$foo: 'bar',
},
}).valueChanges
I'm getting not replaced placeholder $foo
on the server-side:
... WARN 16956 --- [nio-8080-exec-8] graphql.GraphQL : Query failed to validate : '{
bar(id: $foo) {
id
I'm using following apollo npm packages:
"apollo-angular": "^1.7.0",
"apollo-angular-link-http": "^1.8.0",
"apollo-cache-inmemory": "^1.6.3",
"apollo-client": "^2.6.4",
Does anyone have an idea what I'm doing wrong?