apollographql / apollographql/fullstack-tutorial
Uncaught (in promise) Error: GraphQL error: Cannot read property 'id' of null
- 主要语言
- 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
贡献指南
这个仓库没有索引到贡献指南
调研方向
从新用户的复现步骤开始,检查 src/datasources/user.js 第 35 行附近访问 this.context.user.id 的位置。跟踪访客用户在 Book All 期间如何被缓存,然后验证对于没有电子邮件的用户,该流程不再引发报告中的 GraphQL 错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- graphql, javascript
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100