私はgraphCoolをバックエンドとして使用しますが、はすぐに修正されないバグがあります。Apollo/GraphQLからエラーをキャッチする方法
常にこのエラー(ない大したこと)をスローしますdelete
mutation
File
上のスキーマを作る:
「GraphQLエラー:おぉーは、内部サーバーエラーのように見えるhttps://console.graph.cool(コンソールからお問い合わせください。 )または電子メール([email protected])を使用して、あなたのリクエストIDを含めてください: "
コールは機能しますが、コールの後にupdate
関数にアクセスする必要があります。
2種類の溶液: 1.キャッチ私はupdate:
機能を達することができるようにgraphqlエラー、私はこれを行うことができますか? 2. update:
機能を使用せずにストアを更新するにはどうすればよいですか?ここで
は私のコードです:
_deleteImageFile = async() => {
// THIS WORKS, BUT GET AN ERROR
const socialPostId = this.props.socialPost.id
// Tried to wrap the following in try catch without success
await this.props.deleteImageFileMutation({
variables: {
id: this.props.socialPost.image.id
}, //Error hits here "internal service error..."
update: (store) => { //This is never run because of error
console.log('this text will never log')
const userId = localStorage.getItem(GC_USER_ID)
const data = store.readQuery({query: ALL_SOCIAL_POSTS_QUERY,
variables: {
id: userId
}})
// Need to change the store here
store.writeQuery({query: ALL_SOCIAL_POSTS_QUERY, data,
variables: {
id: userId
}}).catch(res => { const errors = res.graphQLErrors; console.log(errors)})
//The catch was an attempt to fix it
}
})
}
リファレンスバグ:https://github.com/graphcool/framework/issues/434
ああ、ダミー突然変異のように何もしませんでしたが、それはあなたに意味を更新する機会を与えるだろうか? –
それは基本的には考えです。 –