Skip to content

Error on client #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ricaragao opened this issue Oct 23, 2018 · 1 comment
Open

Error on client #16

ricaragao opened this issue Oct 23, 2018 · 1 comment

Comments

@ricaragao
Copy link

ricaragao commented Oct 23, 2018

I have an error in my client:

Exception in template helper: TypeError: Template.instance(...).gqlQuery is not a function

Below my code:

import './directors.html';
import gql from 'graphql-tag';

const MY_QUERY = gql`{
	getDirectors {
    label
    hostname
    ip
  }
}`

Template.directors.helpers({
  directors() {
    return Template.instance()
      .gqlQuery({
        query: MY_QUERY
      })
      .get();

  }
});
@unigazer
Copy link

unigazer commented Oct 26, 2018

@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;
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants