`withAuth` and `authScopes` don't combine
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 184
- Avg merge
- 4h 25m
- Merged PRs (30d)
- 137
Description
Hey, I noticed that while you can use both `withAuth` and `authScopes` on the same field, it does not actually combine declarations despite what type declarations lead to think
https://github.com/hayes/pothos/blob/3cebfed6f033ee92c2b3492a3fd6d3002906ab08/packages/plugin-scope-auth/src/field-builders.ts#L58C7-L58C26
Example:
```js
builder.mutationField('updateUserPropery', (t) =>
t.withAuth({ user: true }).boolean({
authScopes(_, args, context) {
// Here `context` will be typed according to `AuthContexts`
// but `{ user: true }` will be overwritten by this function
},
resolve() {
// ...
}
})
)
```
Instead, I'd like both `{ user: true }` and `authScopes(){}` to be merged
Contributor guide
Research direction
Start in packages/plugin-scope-auth/src/field-builders.ts at the referenced line and trace how withAuth and authScopes declarations are applied to a field. Verify the behavior with the provided mutation example and inspect nearby tests if available. Done means both { user: true } and the authScopes() result are preserved together rather than one replacing the other.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100