New to Apollo and I’m just trying to write the most basic query.
When I try to do this using Apollo client I get an exception:
import ApolloClient, { createNetworkInterface } from 'apollo-client';
const networkInterface = createNetworkInterface({ uri: 'http:/localhost:3000/graphql' });
const client = new ApolloClient({
networkInterface,
});
client.query({
query: "{ hello }"
}
The exception details are:
main.js:5168 Uncaught TypeError: Cannot read property 'filter' of undefined
at Object.getFragmentDefinitions (main.js:5168)
at createFragment (main.js:122)
at ApolloClient.query (main.js:230)
at Object.<anonymous> (main.js:77)
at __webpack_require__ (main.js:20)
at main.js:40
at main.js:43
To confirm my query string and graphql server is working, I can run this successfully:
// Works
var xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.open("POST", "/graphql");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.onload = function () {
console.log('data returned:', xhr.response);
}
xhr.send(JSON.stringify({query: "{ hello }"}));
Any help is much appreciated.