1

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

5
  • we would like to see the errors on your console Commented Mar 2, 2020 at 10:27
  • @Abdelhedihlel updated with error screenshot Commented Mar 2, 2020 at 10:32
  • raw response? length 246? Commented Mar 2, 2020 at 10:51
  • @xadm didnt get it Commented Mar 2, 2020 at 11:01
  • compare request body (with playground) ... and bad response body Commented Mar 2, 2020 at 11:35

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

add react-native tag next time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.