0

我在 GRAPHQL 中遇到查询问题

这是我的查询

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

我正在使用反应钩子。
从“@apollo/react-hooks”导入 { useQuery };

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

我得到的错误

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

1 回答 1

0

通过在服务器端的架构中添加 __typename,问题将得到解决。

   query totara_mobile_discussion {
  discussion  : totara_mobile_discussion {
    us
    sys
    __typename
  }
}
于 2021-04-21T10:34:09.153 回答