Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code First Subscription Filter arguments empty #3030

Closed
2 of 4 tasks
ptheofan opened this issue Oct 21, 2023 · 1 comment
Closed
2 of 4 tasks

Code First Subscription Filter arguments empty #3030

ptheofan opened this issue Oct 21, 2023 · 1 comment

Comments

@ptheofan
Copy link

ptheofan commented Oct 21, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In the following code, variables are empty object and the generated schema is missing the arguments.

  @Subscription(() => Vote, {
    nullable: true,
    filter: (payload, variables: { id: string }) => {
      console.log('FILTER:', payload, variables);
      return payload.voteUpdate.id === variables.id;
    },
  })
  voteUpdate(): AsyncIterator<Vote> {
    return pubSub.asyncIterator('voteUpdate');
  }

Schema should have the arguments

type Subscription {
  voteUpdate: Vote
}

Minimum reproduction code

https://github.com/ptheofan/nestjs-subscription-filter-issue

Steps to reproduce

  1. yarn
  2. yarn start:dev
  3. the generated schema is wrong
  4. navigate to http://localhost:3000/graphql
  5. create a subscription
## Arguments missing from schema, should be there.
subscription Subscription {
  voteUpdate(id: $id) {
    id
    value
  }
}

## should have arguments
{
  "id": "default"
}
  1. UpVote (should trigger the subscription)
mutation UpVote($upVoteId: String!) {
upVote(id: $upVoteId) {
    id
    value
  }
}
## with arguments
{
  "upVoteId": "default"
}
  1. Subscription is triggered, payload is correct, variables is empty object (should have the { id: 'default' })

Expected behavior

The subscription in the schema should have the expected arguments and filter variables object should not be empty.

Package version

12.0.9

Graphql version

"@apollo/server": "^4.9.4",
"@nestjs/apollo": "^12.0.9",
"@nestjs/graphql": "^12.0.9",
"graphql": "^16.8.1",
"graphql-subscriptions": "^2.0.0",
"graphql-ws": "^5.14.1",

NestJS version

10.2.7

Node.js version

v18.16.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@ptheofan ptheofan changed the title Code First Subscription Filter payload and arguments undefined Code First Subscription Filter arguments undefined Oct 21, 2023
@ptheofan ptheofan changed the title Code First Subscription Filter arguments undefined Code First Subscription Filter arguments empty Oct 21, 2023
@ptheofan
Copy link
Author

My bad, was missing the @Args directive on the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant