add test case

Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/0a0c5c1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/0a0c5c1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/0a0c5c1a

Branch: refs/heads/master
Commit: 0a0c5c1ac204f7393dfb111ed12ad95082b4c131
Parents: 574c89d
Author: daewon <[email protected]>
Authored: Wed Mar 21 18:56:18 2018 +0900
Committer: daewon <[email protected]>
Committed: Wed Mar 21 18:56:18 2018 +0900

----------------------------------------------------------------------
 .../apache/s2graph/graphql/types/S2Type.scala    | 19 ++++++++-----------
 .../apache/s2graph/graphql/ScenarioTest.scala    | 18 +++++++++++-------
 2 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0a0c5c1a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
----------------------------------------------------------------------
diff --git 
a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala 
b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
index 698de5a..0e7b9ba 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2Type.scala
@@ -125,7 +125,7 @@ object S2Type {
       }.distinct
 
       lazy val connectedLabelFields: List[Field[GraphRepository, Any]] = 
connectedLabels.map(makeLabelField(_, connectedLabelFields))
-      val columnMetasKv = column.metas.filter(ColumnMeta.isValid).map { 
columnMeta => columnMeta.name -> columnMeta.dataType }
+      val columnMetasKv = 
column.metasWithoutCache.filter(ColumnMeta.isValid).map { columnMeta => 
columnMeta.name -> columnMeta.dataType }
       val reservedFields = List("id" -> column.columnType, "timestamp" -> 
"long")
 
       val vertexPropFields = makePropFields(reservedFields ++ columnMetasKv)
@@ -144,13 +144,10 @@ object S2Type {
         ),
         description = Option("desc here"),
         resolve = c => {
-         val id = c.argOpt[Any]("id").toSeq
-          val ids = c.argOpt[List[Any]]("ids").toList.flatten
-          val svc = c.ctx.findServiceByName(service.serviceName).get
+          val ids = c.argOpt[Any]("id").toSeq ++ 
c.argOpt[List[Any]]("ids").toList.flatten
+          val vertices = ids.map(vid => c.ctx.toVertex(vid, column))
 
-          val vertices = (id ++ ids).map(vid => c.ctx.toVertex(vid, column))
-
-          val selectedFields = c.astFields.flatMap{ f =>
+          val selectedFields = c.astFields.flatMap { f =>
             f.selections.map(s => s.asInstanceOf[sangria.ast.Field].name)
           }
 
@@ -183,9 +180,9 @@ object S2Type {
         val vertex: S2VertexLike = c.value match {
           case v: S2VertexLike => v
           case e: S2Edge => if (dir == "out") e.tgtVertex else e.srcVertex
-//          case vp: ServiceParam =>
-//            if (dir == "out") c.ctx.toVertex(label.tgtColumn, vp)
-//            else c.ctx.toVertex(label.srcColumn, vp)
+          //          case vp: ServiceParam =>
+          //            if (dir == "out") c.ctx.toVertex(label.tgtColumn, vp)
+          //            else c.ctx.toVertex(label.srcColumn, vp)
         }
 
         c.ctx.getEdges(vertex, label, dir)
@@ -228,7 +225,7 @@ class S2Type(repo: GraphRepository) {
     val fields = repo.allServices.map { service =>
       val inputFields = service.serviceColumns(false).map { serviceColumn =>
         val idField = InputField("id", 
s2TypeToScalarType(serviceColumn.columnType))
-        val propFields = serviceColumn.metas.filter(ColumnMeta.isValid).map { 
lm =>
+        val propFields = 
serviceColumn.metasWithoutCache.filter(ColumnMeta.isValid).map { lm =>
           InputField(lm.name, OptionInputType(s2TypeToScalarType(lm.dataType)))
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0a0c5c1a/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
----------------------------------------------------------------------
diff --git 
a/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala 
b/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
index 0c08125..d5cbe3a 100644
--- a/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
+++ b/s2graphql/src/test/scala/org/apache/s2graph/graphql/ScenarioTest.scala
@@ -110,7 +110,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
         actual shouldBe expected
       }
 
-      it("should add props to serviceColumn 'user'") {
+      it("should add props(gender) to serviceColumn 'user'") {
         val query =
           graphql"""
 
@@ -322,7 +322,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
     }
 
     describe("Add vertex to kakao.user' and fetch ") {
-      it("add vertices daewon(age: 20), shon(age: 19) to kakao#user") {
+      it("should add vertices: daewon(age: 20, gender: M), shon(age: 19), 
gender: F) to kakao.user") {
         val query =
           graphql"""
 
@@ -333,6 +333,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
                   user: {
                     id: "daewon"
                     age: 20
+                    gender: "M"
                   }
                 }
               },
@@ -341,6 +342,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
                   user: {
                     id: "shon"
                     age: 19
+                    gender: "F"
                   }
                 }
               }]
@@ -367,7 +369,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
         actual shouldBe expected
       }
 
-      it("fetch vertex daewon(age: 20), shon(age: 19)") {
+      it("should fetch vertices: daewon(age: 20, gender: M), shon(age: 19), 
gender: F) from kakao.user") {
         val query =
           graphql"""
 
@@ -376,6 +378,7 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
               user(ids: ["daewon", "shon"]) {
                 id
                 age
+                gender
               }
             }
           }
@@ -389,16 +392,17 @@ class ScenarioTest extends FunSpec with Matchers with 
BeforeAndAfterAll {
                        "kakao": {
                                "user": [{
                                        "id": "daewon",
-                                       "age": 20
+                                       "age": 20,
+                "gender": "M"
                                }, {
                                        "id": "shon",
-                                       "age": 19
+                                       "age": 19,
+                "gender": "F"
                                }]
                        }
                }
         }
-        """
-        )
+        """)
 
         actual shouldBe expected
       }

Reply via email to