update README.md

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

Branch: refs/heads/master
Commit: 0c8057f9a0755490c566128416b4a42cfb6c0202
Parents: 2c3a359
Author: daewon <[email protected]>
Authored: Mon Mar 26 11:19:39 2018 +0900
Committer: daewon <[email protected]>
Committed: Mon Mar 26 11:19:39 2018 +0900

----------------------------------------------------------------------
 s2graphql/README.md                             | 26 ++++++++++----------
 s2graphql/src/main/resources/application.conf   | 10 ++++----
 .../graphql/repository/GraphRepository.scala    |  4 +--
 .../apache/s2graph/graphql/types/S2Type.scala   | 22 +++++++----------
 s2graphql/src/test/resources/application.conf   | 12 ++++-----
 5 files changed, 35 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0c8057f9/s2graphql/README.md
----------------------------------------------------------------------
diff --git a/s2graphql/README.md b/s2graphql/README.md
index be83033..040e8a9 100644
--- a/s2graphql/README.md
+++ b/s2graphql/README.md
@@ -372,9 +372,13 @@ Request
 
 ```graphql
 query {
-  KakaoFavorites(id: "Elmo") {    
-    friends {
-      to
+  KakaoFavorites {    
+    user(id: "Elmo") {
+      friends {
+        to {
+          id
+        }
+      }
     }
   }
 }
@@ -410,10 +414,9 @@ Request
 
 ```graphql
 query {
-  KakaoFavorites {
-    user(id: "Elmo") {
-      id
-                       friends {
+  KakaoFavorites {    
+    user(id: "Elmo") {      
+      friends {        
         to {
           id
         }
@@ -431,7 +434,6 @@ Response
     "KakaoFavorites": {
       "user": [
         {
-          "id": "Elmo",
           "friends": [
             {
               "to": {
@@ -440,12 +442,12 @@ Response
             },
             {
               "to": {
-                "id": "Bert"
+                "id": "Big Bird"
               }
             },
             {
               "to": {
-                "id": "Big Bird"
+                "id": "Bert"
               }
             }
           ]
@@ -480,8 +482,7 @@ mutation {
     ) {
       isSuccess
       message
-      object {
-        id
+      object {        
         name      
       }
     }
@@ -499,7 +500,6 @@ Response
         "isSuccess": true,
         "message": "Mutation successful",
         "object": {
-          "id": 247,
           "name": "post"
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0c8057f9/s2graphql/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/resources/application.conf 
b/s2graphql/src/main/resources/application.conf
index 63ceb53..1844bcc 100644
--- a/s2graphql/src/main/resources/application.conf
+++ b/s2graphql/src/main/resources/application.conf
@@ -24,10 +24,10 @@ akka {
 
 db.default.password = sa
 db.default.user = sa
-s2graph.storage.backend = rocks
-rocks.storage.file.path = rocks_db
-rocks.storage.mode = production
-rocks.storage.ttl = -1
-rocks.storage.read.only = false
+//s2graph.storage.backend = rocks
+//rocks.storage.file.path = rocks_db
+//rocks.storage.mode = production
+//rocks.storage.ttl = -1
+//rocks.storage.read.only = false
 
 

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0c8057f9/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala
----------------------------------------------------------------------
diff --git 
a/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala
 
b/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala
index ac6b167..55abacb 100644
--- 
a/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala
+++ 
b/s2graphql/src/main/scala/org/apache/s2graph/graphql/repository/GraphRepository.scala
@@ -185,7 +185,8 @@ class GraphRepository(val graph: S2GraphLike) {
     val isAsync = args.argOpt("isAsync").getOrElse(false)
     val compressionAlgorithm = 
args.argOpt[String]("compressionAlgorithm").getOrElse(parser.DefaultCompressionAlgorithm)
     val isDirected = args.argOpt[Boolean]("isDirected").getOrElse(true)
-    val options = args.argOpt[String]("options") // TODO: support option type
+    //    val options = args.argOpt[String]("options") // TODO: support option 
type
+    val options = Option("""{"storeVertex": true}""")
 
     val labelTry: scala.util.Try[Label] = management.createLabel(
       labelName,
@@ -226,5 +227,4 @@ class GraphRepository(val graph: S2GraphLike) {
   def allLabels() = Label.findAll()
 
   def findLabelByName(name: String): Option[Label] = Label.findByName(name)
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0c8057f9/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 c2f7f6e..56f008d 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
@@ -154,16 +154,15 @@ object S2Type {
           val ids = c.argOpt[Any]("id").toSeq ++ 
c.argOpt[List[Any]]("ids").toList.flatten
           val vertices = ids.map(vid => c.ctx.toS2VertexLike(vid, column))
 
+          val columnFields = column.metasInvMap.keySet
           val selectedFields = c.astFields.flatMap { f =>
             f.selections.map(s => s.asInstanceOf[sangria.ast.Field].name)
           }
 
-          val a = if (selectedFields.forall(_ == "id")) 
scala.concurrent.Future.successful(vertices)
-          else repo.getVertices(vertices) // fill props
+          val passFetchVertex = selectedFields.forall(f => f == "id" || 
!columnFields(f))
 
-          println(a)
-          a.foreach(println)
-          a
+          if (passFetchVertex) scala.concurrent.Future.successful(vertices)
+          else repo.getVertices(vertices) // fill props
         }
       ): Field[GraphRepository, Any]
     }
@@ -176,13 +175,17 @@ object S2Type {
                         c: Context[GraphRepository, Any]): 
scala.concurrent.Future[S2VertexLike] = {
     implicit val ec = c.ctx.ec
 
+    val columnFields = column.metasInvMap.keySet
     val selectedFields = c.astFields.flatMap { f =>
       f.selections.map(s => s.asInstanceOf[sangria.ast.Field].name)
     }
 
+    // Vertex on edge has invalid `serviceColumn` info
     lazy val newVertex = c.ctx.toS2VertexLike(vertex.innerId, column)
 
-    if (selectedFields.forall(_ == "id")) 
scala.concurrent.Future.successful(vertex)
+    val passFetchVertex = selectedFields.forall(f => f == "id" || 
!columnFields(f))
+
+    if (passFetchVertex) scala.concurrent.Future.successful(vertex)
     else c.ctx.getVertices(Seq(newVertex)).map(_.head) // fill props
   }
 
@@ -326,13 +329,6 @@ class S2Type(repo: GraphRepository) {
           }
         }
 
-        c.ctx.addVertices(edges.toSeq.flatMap { e =>
-          Seq(
-            c.ctx.toS2VertexLike(e.srcVertex.innerId, 
e.srcVertex.serviceColumn),
-            c.ctx.toS2VertexLike(e.tgtVertex.innerId, 
e.tgtVertex.serviceColumn)
-          )
-        })
-
         c.ctx.addEdges(edges.toSeq)
       }
     )

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/0c8057f9/s2graphql/src/test/resources/application.conf
----------------------------------------------------------------------
diff --git a/s2graphql/src/test/resources/application.conf 
b/s2graphql/src/test/resources/application.conf
index d070a59..e412f2f 100644
--- a/s2graphql/src/test/resources/application.conf
+++ b/s2graphql/src/test/resources/application.conf
@@ -25,9 +25,9 @@ akka {
 db.default.url="jdbc:h2:file:./var/metastore;MODE=MYSQL",
 db.default.password = sa
 db.default.user = sa
-s2graph.storage.backend = rocks
-
-rocks.storage.file.path = rocks_db
-rocks.storage.mode = production
-rocks.storage.ttl = -1
-rocks.storage.read.only = false
\ No newline at end of file
+//s2graph.storage.backend = rocks
+//
+//rocks.storage.file.path = rocks_db
+//rocks.storage.mode = production
+//rocks.storage.ttl = -1
+//rocks.storage.read.only = false
\ No newline at end of file

Reply via email to