Skip to content

Commit

Permalink
fix(GraphQL): Fix case where Dgraph type was not generated for GraphQ…
Browse files Browse the repository at this point in the history
…L interface (#5738)

* Generate type in Dgraph for interface using other interface

* Add test
  • Loading branch information
vardhanapoorv authored Jul 3, 2020
1 parent 55594de commit c6a0dfa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions graphql/schema/dgraph_schemagen_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,49 @@ schemas:
}
C.dob: dateTime .
-
name: "interface using other interface generate type in dgraph"
input: |
interface A {
id: ID!
data: [D]
}
type C implements A {
lname: String
}
interface B {
name: String! @id
fname: String!
}
type D implements B {
link: A
correct: Boolean!
}
output: |
type A {
A.data
}
A.data: [uid] .
type C {
A.data
C.lname
}
C.lname: string .
type B {
B.name
B.fname
}
B.name: string @index(hash) @upsert .
B.fname: string .
type D {
B.name
B.fname
D.link
D.correct
}
D.link: uid .
D.correct: bool .
-
name: "Schema with @dgraph directive."
input: |
Expand Down
2 changes: 1 addition & 1 deletion graphql/schema/schemagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func genDgSchema(gqlSch *ast.Schema, definitions []string) string {

var typStr string
switch gqlSch.Types[f.Type.Name()].Kind {
case ast.Object:
case ast.Object,ast.Interface:
typStr = fmt.Sprintf("%suid%s", prefix, suffix)

if parentInt == nil {
Expand Down

0 comments on commit c6a0dfa

Please sign in to comment.