From c6a0dfa4c6f87ab8d3708701027e2ef5859eb2d4 Mon Sep 17 00:00:00 2001 From: Apoorv Vardhan Date: Fri, 3 Jul 2020 12:14:24 +0530 Subject: [PATCH] fix(GraphQL): Fix case where Dgraph type was not generated for GraphQL interface (#5738) * Generate type in Dgraph for interface using other interface * Add test --- graphql/schema/dgraph_schemagen_test.yml | 43 ++++++++++++++++++++++++ graphql/schema/schemagen.go | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/graphql/schema/dgraph_schemagen_test.yml b/graphql/schema/dgraph_schemagen_test.yml index 3593eb3072f..0f4ff113f1c 100644 --- a/graphql/schema/dgraph_schemagen_test.yml +++ b/graphql/schema/dgraph_schemagen_test.yml @@ -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: | diff --git a/graphql/schema/schemagen.go b/graphql/schema/schemagen.go index 283e005c646..c6bbe7ebb4b 100644 --- a/graphql/schema/schemagen.go +++ b/graphql/schema/schemagen.go @@ -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 {