react-native android 应用程序发布版本的 Graphql 网络错误

Graphql Network Error on release version of react-native android app

我开发了一个使用 graphql 的本机反应 android 应用程序,我可以连接到 graphql 服务器并执行突变和查询,但 仅在调试版本上 的应用程序。当我构建应用程序的 发布版本 并在我的 phone 上 运行 时,问题就出现了。在执行登录突变时,我面临
'networkError: ', '{"line":123,"column":7285,"sourceURL":"index.android.bundle"}'

Graphql初始化代码,

const httpLink = createHttpLink({
  uri: 'https://<IP>:4050'
})

const authLink = setContext((_, { headers }) => {
  getMyValue(AUTH_TOKEN)
  return {
    headers: {
      ...headers,
      authorization: token ? `Bearer ${token}` : ''
  }
})

const client = new ApolloClient({
  link: authLink.concat(httpLink),
  cache: new InMemoryCache()
})

这是抛出错误的组件,

<Mutation
                mutation={gql`
                  mutation login($username:String!,$password:String!){
                    login(username:$username,password:$password)
                  }
                `}
                variables={{ username, password }}
                onError={(err) => {
                  console.log('err: ', err);
                }}
                onCompleted={data => {...}}
              >
                {mutation => (
                  <Button full style={styles.loginButton}
                    onPress={() => {
                        mutation()
                    }}>
                      <Text>Login</Text>
                  </Button>
                )}
              </Mutation>

在应用程序的调试版本上,它转到 onCompleted 代码块,这也是我想要的应用程序发布版本的代码块。相反,在应用程序的发布版本中,它会转到 onError 代码块并抛出网络错误。

将此行添加到您的 android 清单应用程序标记中

android:usesCleartextTraffic="true"