hayes/pothos

`withAuth` and `authScopes` don't combine

Open

#1,192 opened on Apr 18, 2024

View on GitHub
 (2 comments) (0 reactions) (0 assignees)TypeScript (183 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (2,609 stars)
PR merge metrics
 (PR metrics pending)

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:

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