-
Notifications
You must be signed in to change notification settings - Fork 228
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
Draft: Add filter tests for discussion #356
Conversation
@erikwrede not sure if I'm understanding your point about MultipleOfType correctly. Currently, the syntax would support this kind of query:
SQLAlchemy: Is this kind of query you mentioned in slack? Where does MultipleOfType come in to support this?
SQLAlchemy: Let me know if I have anything wrong here. |
Hey, sorry for not following up with an example. Think of my comment like a friendsWith filter on User that has a list of friends. Currently, you could only filter for "A is friends with one of B or C." What's missing is "A is friends with ALL of B and C" or "A's friends are exactly B and C" EDIT: Example: Student is enrolled exactly in Courses
Filtering it this way is certainly more complex than regular relationship filters like the ones you mentioned above. However, we included these kinds of filters in the document (Section 1:n relationships, Here is where the intermediate This is why it's absolutely necessary to have these intermediate relationship filters. This would be the only way to proxy additional logic on relationships or add new functionality while preserving backward compatibility. I've typed this down in an example below: type StudentFilter
name: StringFilter
courseEnrolments: CourseEnrolmentRelationshipFilter
type CourseEnrolmentRelationshipFilter
contains: CourseEnrolmentFilter
containsAllOf: [CourseEnrolmentFilter]
containsExactly: [CourseEnrolmentFilter] query {
students(filter: {courseEnrolments:
{contains: {course:
{name:{in: ["SQL", "Graphene"]}}
}}
}) {
name
}
} The above example would semantically mean "Student who is enrolled either in the SQL or the Graphene Course." The following example would be equal to my example from above (Student is enrolled exactly in Courses query {
students(filter: {courseEnrolments:
{containsExactly:
[{course:
{name:{eq: "SQL"}}
}, {course:
{name:{eq: "Graphene"}}
}]
}
}) {
name
}
} |
Thanks for the detailed examples here. This makes a lot more sense to me and I'll update the tests to reflect the desired behavior of containsAllOf and containsExactly. Happy to aim for this support in the first release. Are there any other default RelationshipFilter behaviors we want to support? Maybe a better question is how can we make it easy for users to augment custom filters on top of this in the case they'd like to implement something like containsOneOf or containsNoneOf? |
Sqlalchemy has .startswith and .endswith that we should consider as
filtering options.
I discovered an issue with VARBINARY filtering with .startswith and
.endswith that should have been fixed. You may want to take a look just in
case as it may have a material impact:
sqlalchemy/sqlalchemy#8253 (comment)
… |
Just added a couple subtests for a As for I'm going to go ahead and start implementing basic filtering on top of this PR rebased off #355, but will keep updating this as needed. |
Closing in favor of #357 |
The purpose of this Draft PR is to facilitate discussion around implementing filters and to provide a concrete set of test cases that filtering must support in order to be incorporated into graphene-sqlalchemy.
So far, I have added test cases for the following:
I still need to implement test cases for the following:
Please feel free to discuss general topics related to implementing filters here as well as specific improvements needed to testing and filter syntax.