graphql icon indicating copy to clipboard operation
graphql copied to clipboard

fix(graphql): readonly arrays not allowed in decorator input

Open CarsonF opened this issue 1 year ago • 2 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [x] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Other... Please describe:

What is the current behavior?


const interfaces = [A, B] as const;

@ObjectType({
  implements: interfaces, // error
})

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

CarsonF avatar Jun 07 '24 15:06 CarsonF

minor changes to support both array and read only arrays

These represent the same thing. Mutable arrays are a superset of read-only ones. But if this style is preferred I can switch it.

CarsonF avatar Jun 09 '24 16:06 CarsonF

I just noticed something that would break due to that ReadonlyArray:

const imports: ResolveFieldOptions['middleware'] = [];
imports.push(() => {})

because we can't invoke .push on readonly arrays

and I believe that we shouldn't prevent that usage

micalevisk avatar Jun 09 '24 17:06 micalevisk