简体   繁体   中英

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

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"
}

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
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM