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

graphql: Introduce @cascade in GraphQL #5511

Merged
merged 5 commits into from
May 27, 2020

Conversation

abhimanyusinghgaur
Copy link
Contributor

@abhimanyusinghgaur abhimanyusinghgaur commented May 23, 2020

Fixes #4789.
Fixes #GRAPHQL-277.


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 May 23, 2020
@abhimanyusinghgaur abhimanyusinghgaur marked this pull request as ready for review May 26, 2020 05:46
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 40 of 40 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @abhimanyusinghgaur and @MichaelJCompton)


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

							},{
								"reputation": 4.6,
								"posts": []

You should try and fetch title as well for this query and then because you have @cascade on posts it should not be returned.


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

  gqlquery: |
    query {
      getAuthor(id: "0x1") @cascade {

Is @cascade allowed in Dgraph on predicates without children? If not, then what happens in that case from GraphQL?


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

      queryAuthor {
        dob
        posts @cascade {

Also add a test case where the directive is both on root and a field below.


graphql/schema/gqlschema.go, line 121 at r1 (raw file):

directive @custom(http: CustomHTTP) on FIELD_DEFINITION
directive @remote on OBJECT | INTERFACE
directive @cascade on FIELD

So the directive isn't allowed while querying interfaces?


graphql/schema/wrappers.go, line 1162 at r1 (raw file):

			continue
		}
		if m.Cascade() && !f.Cascade() {

Are we adding the directive to the field here from the mutation so that it is applied to the query after?

Copy link
Contributor Author

@abhimanyusinghgaur abhimanyusinghgaur left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @MichaelJCompton and @pawanrawal)


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

Previously, pawanrawal (Pawan Rawal) wrote…

You should try and fetch title as well for this query and then because you have @cascade on posts it should not be returned.

Done.


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

Previously, pawanrawal (Pawan Rawal) wrote…

Is @cascade allowed in Dgraph on predicates without children? If not, then what happens in that case from GraphQL?

It is allowed on such predicates. I checked, it didn't give any errors and worked fine.


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

Previously, pawanrawal (Pawan Rawal) wrote…

Also add a test case where the directive is both on root and a field below.

Done.


graphql/schema/gqlschema.go, line 121 at r1 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

So the directive isn't allowed while querying interfaces?

Doesn't matter what type is returned I guess.
As all the queries/mutations are basically fields of type Query and type Mutation, so cascade can be applied on them, and any field in their selection set. So, anything where @cascade is going to be applied is going to be a field.


graphql/schema/wrappers.go, line 1162 at r1 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Are we adding the directive to the field here from the mutation so that it is applied to the query after?

Yes, so that if @cascade was given on mutation itself, then it should get applied for the query which gets executed to fetch the results of that mutation.

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.

:lgtm:

Reviewed 3 of 3 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MichaelJCompton)

Copy link
Contributor

@MichaelJCompton MichaelJCompton left a comment

Choose a reason for hiding this comment

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

:lgtm:

Just to master for this one - it's a new feature, so it won't go into 20.03

Can you make sure you mark the milestone on the github issue and the fix version on the jira ticket at 20.07...

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @abhimanyusinghgaur)


graphql/resolve/mutation_query_test.yaml, line 157 at r2 (raw file):

    gqlquery: |
      mutation {
        ADD_UPDATE_MUTATION @cascade {

nice

@abhimanyusinghgaur abhimanyusinghgaur added this to the 20.07.0 milestone May 27, 2020
Copy link
Contributor Author

@abhimanyusinghgaur abhimanyusinghgaur left a comment

Choose a reason for hiding this comment

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

Done.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MichaelJCompton)


graphql/resolve/mutation_query_test.yaml, line 157 at r2 (raw file):

Previously, MichaelJCompton (Michael Compton) wrote…

nice

Done.

@MichaelJCompton MichaelJCompton modified the milestones: 20.07.0, Dgraph v20.07.0 May 27, 2020
@abhimanyusinghgaur abhimanyusinghgaur merged commit d029c86 into master May 27, 2020
@abhimanyusinghgaur abhimanyusinghgaur deleted the abhimanyu/graphql-cascade branch May 27, 2020 13:45
@abhimanyusinghgaur abhimanyusinghgaur added the kind/feature Something completely new we should consider. label May 27, 2020
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 18, 2020
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. kind/feature Something completely new we should consider.
Development

Successfully merging this pull request may close these issues.

[GraphQL] Introducing @cascade in the GraphQL API?
3 participants