使用react native
注册/登录我的移动应用时出现以下错误> (node:1474) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): JsonWebTokenError: jwtmalformed
>
> ERRO[0166] Error sending request to origin. This likely means that the origin GraphQL server did not respond to theproxied request. To resolve this, verify the Origin specification in the Engine configuration matches the corresponding GraphQL server. error="Post http://[::]:51865/graphql: net/http: request canceled (Client.Timeout exceeded while awaiting headers)" url="http://[::]:51865/graphql"
我将错误隔离到下面的客户端状态。它可能是由于我的apollo链接状态查询/突变而发生的。删除我的客户端状态后,我的移动应用可以正常注册/登录。一旦我将客户端状态代码重新放入,我再次收到上述错误
任何掌握反应和apollo graphql的人都可以帮助我找出错误的地方。由于apollo的错误报告相当模糊(此时此刻),我很难确定错误发生的具体位置
const client = new ApolloClient({
uri: "http://localhost:5000/graphql",
...
clientState: {
defaults: defaultState,
resolvers: {
Query: {
getMeInfo: (_, d, { cache }) => {
return defaultState.me;
}
},
Mutation: {
updateMeInfo: (_, { _id, email, firstName, lastName }, { cache }) => {
// KIV
console.log("CACHE", cache);
},
resetCurrentGame: (_, d, { cache }) => {
cache.writeData({ data: defaultState });
return defaultState.currentGame;
},
updateGame: (_, { index, value }, { cache }) => {
const prevState = cache.readQuery({ query: CURRENT_GAME });
const data = {
currentGame: {
...prevState.currentGame,
[index]: value
}
};
cache.writeData({
query: CURRENT_GAME,
data
});
return data.currentGame;
}
}
}
},...