Skip to content

args are not validated before being passed to subscribe #535

Closed
@backbone87

Description

@backbone87

Describe the bug
Args are not validated before being passed to subscribe

To Reproduce

@ArgsType()
class MyArgs {
  @Field(() => String)
  @MinLength(1)
  public name!: string;
}

@Resolver()
export default class MySubscriptions {
  @Subscription(() => String, {
    subscribe: (root, { name }: MyArgs) => {
      return { next: async () => ({ done: true }) };
    },
  })
  public observe(@Args(() => MyArgs ) args: MyArgs): string {
    return args.name;
  }
}

-> Subscribe with name set to empty string
-> No error (error would occur on first resolver call, but we have empty observable, also it should not (re)validate on resolver call)

Expected behavior
Arguments being validated before being passed to subscribe

Enviorment (please complete the following information):

  • OS: Windows
  • Node: 12
  • Package version: 0.17.6
  • TypeScript version: 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Community 👨‍👧Something initiated by a communityDuplicate 🔑This issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions