1
votes

in my local http://localhost:3000/graphql query is working like below... enter image description here

but when I am querying through apollo client its response coming empty

import {InMemoryCache, gql, ApolloClient, HttpLink} from 'apollo-boost';
const cache = new InMemoryCache();
const client = new ApolloClient({
  cache,
  link: new HttpLink({
    uri: 'http://localhost:3000/graphql',
    credentials: 'same-origin',
  }),
  },
});

client
  .query({
    query: gql`
      {
        brands {
          _id
        }
      }
    `,
  })
  .then(data => console.log(data))
  .catch(error => {
    // its coming in this section
    console.log(error);
  });

Don't know what I am missing. Any help is appreciated Thanks !!!

below are the screenshots, when I am trying to query from frontend side

enter image description here enter image description here enter image description here enter image description here

1
we would like to see the errors on your console - abdelhedi hlel
@Abdelhedihlel updated with error screenshot - Rituraj ratan
raw response? length 246? - xadm
@xadm didnt get it - Rituraj ratan
compare request body (with playground) ... and bad response body - xadm

1 Answers

2
votes

solved by adding in app.js

global.XMLHttpRequest = global.originalXMLHttpRequest || global.XMLHttpRequest;
global.FormData = global.originalFormData || global.FormData;

if (window.FETCH_SUPPORT) {
  window.FETCH_SUPPORT.blob = false;
} else {
  global.Blob = global.originalBlob || global.Blob;
  global.FileReader = global.originalFileReader || global.FileReader;
}

reference: https://github.com/jhen0409/react-native-debugger/issues/382#issuecomment-544226529