-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(GraphQL): optimize eq filter queries #7895
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @minhaj-shakeel)
cherry-pick 7895 attempt Fixes GQLSAAS-1236. This PR optimizes `eq` filter GraphQL queries. For ex: The below DQL query: ``` query { queryPerson(filter: {nick: {eq: "Dgraph"}}){ id name nick } } ``` will now be written into: ``` query { queryPerson(func: eq(Person.nick, "Dgraph")) @filter(type(Person)) { Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` which was earlier written into:- ``` query { queryPerson(func: type(Person)) @filter(eq(Person.nick, "Dgraph")){ Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ```
Fixes GQLSAAS-1236. This PR optimizes `eq` filter GraphQL queries. For ex: The below DQL query: ``` query { queryPerson(filter: {nick: {eq: "Dgraph"}}){ id name nick } } ``` will now be written into: ``` query { queryPerson(func: eq(Person.nick, "Dgraph")) @filter(type(Person)) { Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` which was earlier written into:- ``` query { queryPerson(func: type(Person)) @filter(eq(Person.nick, "Dgraph")){ Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ```
We should point out in the release notes that the optimization is not realized when complex filters (AND, NOT, OR) are present in the GraphQL query. For instance see the "Filter with nested 'and'" test in query_test.yaml |
fix(GraphQL): optimize eq filter queries (#7895)
This was not squashed & merged, the original PR was this #8303 Fixes GQLSAAS-1236. This PR optimizes `eq` filter GraphQL queries. For ex: The below DQL query: ``` query { queryPerson(filter: {nick: {eq: "Dgraph"}}){ id name nick } } ``` will now be written into: ``` query { queryPerson(func: eq(Person.nick, "Dgraph")) @filter(type(Person)) { Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` which was earlier written into:- ``` query { queryPerson(func: type(Person)) @filter(eq(Person.nick, "Dgraph")){ Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` <!-- Change Github PR Title Your title must be in the following format: - `topic(Area): Feature` - `Topic` must be one of `build|ci|docs|feat|fix|perf|refactor|chore|test` Sample Titles: - `feat(Enterprise)`: Backups can now get credentials from IAM - `fix(Query)`: Skipping floats that cannot be Marshalled in JSON - `perf: [Breaking]` json encoding is now 35% faster if SIMD is present - `chore`: all chores/tests will be excluded from the CHANGELOG --> ## Problem <!-- Please add a description with these things: 1. Explain the problem by providing a good description. 2. If it fixes any GitHub issues, say "Fixes #GitHubIssue". 3. If it corresponds to a Jira issue, say "Fixes DGRAPH-###". 4. If this is a breaking change, please prefix `[Breaking]` in the title. In the description, please put a note with exactly who these changes are breaking for. --> ## Solution <!-- Please add a description with these things: 1. Explain the solution to make it easier to review the PR. 2. Make it easier for the reviewer by describing complex sections with comments. --> Co-authored-by: minhaj-shakeel <[email protected]>
This PR optimizes `eq` filter GraphQL queries. The below DQL query: ``` query { queryPerson(filter: {nick: {eq: "Dgraph"}}){ id name nick } } ``` will now be written into: ``` query { queryPerson(func: eq(Person.nick, "Dgraph")) @filter(type(Person)) { Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` which was earlier written into:- ``` query { queryPerson(func: type(Person)) @filter(eq(Person.nick, "Dgraph")){ Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ```
This PR optimizes `eq` filter GraphQL queries. The below DQL query: ``` query { queryPerson(filter: {nick: {eq: "Dgraph"}}){ id name nick } } ``` will now be written into: ``` query { queryPerson(func: eq(Person.nick, "Dgraph")) @filter(type(Person)) { Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ``` which was earlier written into:- ``` query { queryPerson(func: type(Person)) @filter(eq(Person.nick, "Dgraph")){ Person.id : uid Person.name : Person.name Person.nick : Person.nick } } ```
Fixes GQLSAAS-1236.
This PR optimizes
eq
filter GraphQL queries.For ex:
The below DQL query:
will now be written into:
which was earlier written into:-
This change is