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

feat(GraphQL): add support for IN filter #6662

Merged
merged 9 commits into from
Oct 8, 2020
Merged

Conversation

minhaj-shakeel
Copy link
Contributor

@minhaj-shakeel minhaj-shakeel commented Oct 6, 2020

Fixes GRAPHQL-712.

This PR adds support for the IN filter in GraphQL.
For the given type State having @id directive at the field code :

type State {
        code: String! @id
        name: String!
	capital: String
}

Suppose we want to query States having either code = abc or def, then the corresponding GraphQL query is:

query {
      queryState(filter: {code: {in : ["abc", "def"]}}){
        code 
        name
      }
    }

This change is Reviewable

Docs Preview: Dgraph Preview

@github-actions github-actions bot added the area/graphql Issues related to GraphQL support on Dgraph. label Oct 6, 2020
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 3 rules errored during the review.

Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 6 rules errored during the review.

Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 1 rules errored during the review.

Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issues found. 8 rules errored during the review.

// in takes List of Scalars as argument, for eg:
// code : { in: {"abc", "def", "ghi"} } -> eq(State.code,"abc","def","ghi")
case "in":
vals := val.([]interface{})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unchecked type assertions can cause panics. Check for success with the x, ok := y.(type) style.

View Rule

Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 8 rules errored during the review.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 44 of 44 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @codelingo[bot], @MichaelJCompton, and @minhaj-shakeel)


graphql/e2e/common/query.go, line 350 at r1 (raw file):

func InFilter(t *testing.T) {
	addStateParams := &GraphQLParams{

inFilter


graphql/e2e/common/query.go, line 368 at r1 (raw file):

	}

	gqlResponse := addStateParams.ExecuteAsPost(t, GraphqlURL)

Can we also add a test where in used for updateState.


graphql/resolve/query_rewriter.go, line 1068 at r1 (raw file):

Previously, codelingo[bot] wrote…

Unchecked type assertions can cause panics. Check for success with the x, ok := y.(type) style.

View Rule

Add a comment saying that

No need to check for type as this would not pass the GraphQL validation if vals was not a list.


graphql/resolve/query_test.yaml, line 5 at r1 (raw file):

  gqlquery: |
    query {
      queryState(filter: {code: {in: ["abc", "def", "ghi"]}}) {

Add a case with both in and eq in an AND/OR condition

@minhaj-shakeel minhaj-shakeel merged commit 6b43353 into master Oct 8, 2020
@minhaj-shakeel minhaj-shakeel deleted the minhaj/in-filter branch October 8, 2020 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph.
Development

Successfully merging this pull request may close these issues.

2 participants