"message": "Network error: fetcher is not a function"

Nikhil-Kumar

MVP

29-09-2020

I am getting above mentioned error I am using below code snippet to get result from Magento graphql in Node JS:

const gql = require("graphql-tag");
const {ApolloClient} = require("apollo-client");
const fetch = require("node-fetch");
const{createHttpLink} = require("apollo-link-http");
const {InMemoryCache} = require("apollo-cache-inmemory");

const httpLink = createHttpLink({
uri: 'http://localhost:3001/graphql',
fetch: fetch,
});

const client = new ApolloClient({
link: httpLink,
cache: new InMemoryCache(),
});

var queryField = `query {
countries {
id
available_regions {
name
code
}
}
}

`;

const query = gql(queryField);
var variables = {};

const result = client.query({
    query,
    variables
  });

I tried with apollo-client 3 as well as 2.

There seems to be issue in getting the results.

Accepted Solutions (0)