apollographql / apollographql/fullstack-tutorial

Uncaught (in promise) Error: GraphQL error: Cannot read property 'id' of null

オープン
#62 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
1.2k
フォーク
808
PR マージ指標
30日以内にマージされた PR はありません

説明

Steps to reproduce:

1. Login as a new user (hasn't entered their email yet)
2. Select a trip from the home page
3. Add trip to cart
4. Go to cart
5. Click Book All

It will explode with: Uncaught (in promise) Error: GraphQL error: Cannot read property 'id' of null.

Looking at the error more closely reveals that we are caching the guest user somewhere. The error comes back from

```
// src/datasources/user.js:35
const userId = this.context.user.id;
if (!userId) return;
```

This means the user context is null

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

新しいユーザーでの再現手順から始め、this.context.user.id にアクセスしている src/datasources/user.js の35行目付近を調べます。Book All 中にゲストユーザーがどのようにキャッシュされるかを追跡し、その後、メールアドレスのないユーザーに対して報告された GraphQL エラーがフローで発生しなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
graphql, javascript
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。