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

Subscription filter #317

Closed
manlyman29 opened this issue Jun 21, 2020 · 5 comments
Closed

Subscription filter #317

manlyman29 opened this issue Jun 21, 2020 · 5 comments

Comments

@manlyman29
Copy link

manlyman29 commented Jun 21, 2020

I have been trying to apply filters to subscription but as soon as any sort of filter as applied subscription doesn't receives any update, I have attached two corresponding mutation and subscription i use to check filter:

mutation {
  updateOneUser(input:{id:1, update:{ lastName:"ss" } }) {
    firstName
    lastName
  }
}
subscription {
  updatedOneUser(input: { filter: { id: { eq:"1" } } }) {
    id
    firstName
    lastName
  }
}

With filter id filter being removed from subscription it receives updates. But on all records.

Thanks!

@doug-martin
Copy link
Owner

What if you change to id: { eq: 1 } ? The eq comparison will be strict eq, I think in this case you are using a string for the ID but it is actually a number.

@manlyman29
Copy link
Author

Thanks for response,
I tried that too when i was testing but had no luck. I also tried with other filters (in, gt etc).
Also tried with filtering other fields but couldn't get any response as soon as any sort of filter was applied.

@doug-martin
Copy link
Owner

@innomal I'm curious is your id field using the ID graphql type?

In local testing it looks like that always serializes to a string, which causes this to break because of the strict equal. Once I changed the id type to Int the subscription filtered properly.

@manlyman29
Copy link
Author

Yes it is set to ID, I have attached dto class for reference.

@ObjectType('User')
export class UserDTO {
    
    @FilterableField(() => ID)
    id!: number;
    
    @FilterableField()
    mobileNumber?:number;

    @Field()
    firstName?: string;
    
    @FilterableField()
    lastName?: string;
}

I can confirm the issue i am experiencing seems to be about ID field. I could get a subscription from a string field filter correctly but not yet with id.
Also just an idea but maybe it could be useful to be possible to filter based on fields. Like only if lastName & firstName was changed emit an update.

@doug-martin
Copy link
Owner

@innomal this should be fixed in v0.17.3. Thanks again!

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

No branches or pull requests

2 participants