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

fix(GraphQL):This PR allows to use fragments on interfaces while querying other interface. #6964

Merged
merged 6 commits into from
Nov 24, 2020

Conversation

JatinDev543
Copy link
Contributor

@JatinDev543 JatinDev543 commented Nov 24, 2020

Fixes GRAPHQL-863
Consider the below schema, Human implements both character and Employee interfaces.

interface Employee { ... }
interface Character { ... }
type Human implements Character & Employee { ... }
type Droid implements Character { ... }

While Querying Character interfaces which can return an object of Droid or Human, we will be able to use fragment on Employee interface if the returned object is of type Human and ignores it if the returned object is of type Droid.


This change is Reviewable

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

netlify bot commented Nov 24, 2020

Deploy preview for dgraph-docs ready!

Built with commit 08393f5

https://deploy-preview-6964--dgraph-docs.netlify.app

Copy link
Contributor

@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.

:lgtm:

Nice fix!

Reviewed 2 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @jatindevdg, @MichaelJCompton, and @pawanrawal)


graphql/resolve/query_test.yaml, line 1939 at r2 (raw file):

"queryCharacter with fragment on interface and type"

fragment on interface implemented by type which implements multiple interfaces in query on some other interface


graphql/schema/request.go, line 285 at r2 (raw file):

Type

typ

local variables should always be lowercase. So, lets change this to typ (as type is a keyword)

Copy link
Contributor Author

@JatinDev543 JatinDev543 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: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @abhimanyusinghgaur, @MichaelJCompton, and @pawanrawal)


graphql/resolve/query_test.yaml, line 1939 at r2 (raw file):

Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
"queryCharacter with fragment on interface and type"

fragment on interface implemented by type which implements multiple interfaces in query on some other interface

changed.


graphql/schema/request.go, line 285 at r2 (raw file):

Previously, abhimanyusinghgaur (Abhimanyu Singh Gaur) wrote…
Type

typ

local variables should always be lowercase. So, lets change this to typ (as type is a keyword)

Ohh...changed.

@JatinDev543 JatinDev543 merged commit f810e4e into master Nov 24, 2020
@JatinDev543 JatinDev543 deleted the jatin/GRAPHQL-863 branch November 24, 2020 10:15
JatinDev543 added a commit that referenced this pull request Nov 24, 2020
…ying other interface. (#6964)

Fixes GRAPHQL-863
Consider the below schema, Human implements both character and Employee interfaces.

interface Employee { ... }
interface Character { ... }
type Human implements Character & Employee { ... }
type Droid implements Character { ... }

While Querying Character interfaces which can return an object of Droid or Human, we will be able to use fragment on Employee interface if the returned object is of type Human and ignores it if the returned object is of type Droid.

(cherry picked from commit f810e4e)
JatinDev543 added a commit that referenced this pull request Nov 26, 2020
…ying other interface. (#6964) (#6966)

Fixes GRAPHQL-863
Consider the below schema, Human implements both character and Employee interfaces.

interface Employee { ... }
interface Character { ... }
type Human implements Character & Employee { ... }
type Droid implements Character { ... }

While Querying Character interfaces which can return an object of Droid or Human, we will be able to use fragment on Employee interface if the returned object is of type Human and ignores it if the returned object is of type Droid.

(cherry picked from commit f810e4e)
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