Open ricaragao opened 6 years ago
@ricaragao Try it like this
import gql from 'graphql-tag';
import ApolloClient from 'apollo-client';
import { ApolloLink } from 'apollo-link'
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
import { MeteorAccountsLink } from 'meteor/apollo'
import { setup } from 'meteor/swydo:blaze-apollo';
const client = new ApolloClient({
link: ApolloLink.from([
new MeteorAccountsLink(),
new HttpLink({
uri: '/graphql'
})
]),
cache: new InMemoryCache()
});
setup({ client });
Template.directors.helpers({
directors() {
const MY_QUERY = gql`
{
getDirectors {
label
hostname
ip
}
}`
return Template.instance().gqlQuery({ query: MY_QUERY }).get().getDirectors;
}
});
I have an error in my client:
Exception in template helper: TypeError: Template.instance(...).gqlQuery is not a function
Below my code: