Missing field __typename while using graphql query with apollo react-hooks

1.2k views Asked by At

I'm facing a issue with query in GRAPHQL

Here is my query

const discussionform = gql`
  query totara_mobile_discussion {
    discussion {
      __typename
      us
      sys
    }
  }
`;

I'm using react-hooks.
import { useQuery } from "@apollo/react-hooks";

const Profile = ({ navigation }: ProfileProps) => {
  const { loading, data, error } = useQuery(discussionform);
  if (loading) return <Loading testID={"test_ProfileLoading"} />;
  return (
    <View>
      <Text>{data}</Text>
    </View>
  );
};

The error i'm getting

Missing field __typename in {
  "us": "General news and announcements",
  "sys": "tesr"
}
1

There are 1 answers

0
sreenu malae On

By adding the __typename in the schema in serverside the issue will be resolved.

   query totara_mobile_discussion {
  discussion  : totara_mobile_discussion {
    us
    sys
    __typename
  }
}