graphile / graphile/crystal

Create a lint rule to detect bad patterns in plans

Open
#2,494 0 comments 0 reactions 0 assignees View on GitHub
✨ feature
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

```diff
plans: {
User: {
friends($user) {
- const $db = context().get('db');
const $ids = $user.get('friendIds');
return each($ids, $id => {
+ const $db = context().get('db');
return loadOne($id, $db, getFriendById);
});
}
}
}
```

The `$db` in the outer scope will have been garbage collected by the time the `each()` callback is called, so the `loadOne` call will raise an error due to trying to depend on deleted step.

Either:

1. Don't delete this step (risky because it opens the door to much worse behavior!), or
2. Add a lint rule that detects this and has the step be created inside the `each` callback instead.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.