change deleteServiceColumnParamType

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

Branch: refs/heads/master
Commit: 36e4e03c4ecc17fba75416bfa56a90ad3f174071
Parents: bab13a3
Author: daewon <[email protected]>
Authored: Wed Feb 28 18:33:15 2018 +0900
Committer: daewon <[email protected]>
Committed: Wed Feb 28 18:33:15 2018 +0900

----------------------------------------------------------------------
 .../graphql/repository/GraphRepository.scala    | 12 ++++---
 .../graphql/types/S2ManagementType.scala        | 35 ++++++++++++++++----
 2 files changed, 37 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/36e4e03c/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 c3712d4..edaebbd 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
@@ -161,11 +161,15 @@ class GraphRepository(val graph: S2GraphLike) {
     Try { management.createServiceColumn(serviceName, columnName, columnType, 
props) }
   }
 
-  def deleteServiceColumn(args: Args): Try[ServiceColumn] = {
-    val serviceName = args.arg[String]("serviceName")
-    val columnName = args.arg[String]("columnName")
+  def deleteServiceColumn(args: Args): List[Try[ServiceColumn]] = {
+    println(args)
+    //Args(Map(s2graph -> Some(Map(columnName -> 
_))),Set(),Set(s2graph),Set(),TrieMap())
+    val serviceColumns = args.raw.collect { case (serviceName, Some(map: 
Map[String, String])) =>
+      val columnName = map("columnName")
+      Management.deleteColumn(serviceName, columnName)
+    }
 
-    Management.deleteColumn(serviceName, columnName)
+    serviceColumns.toList
   }
 
   def createLabel(args: Args): Try[Label] = {

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/36e4e03c/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2ManagementType.scala
----------------------------------------------------------------------
diff --git 
a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2ManagementType.scala
 
b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2ManagementType.scala
index 94bd466..b1cc299 100644
--- 
a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2ManagementType.scala
+++ 
b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/S2ManagementType.scala
@@ -91,6 +91,27 @@ class S2ManagementType(repo: GraphRepository) {
 
   lazy val IndicesArg = Argument("indices", 
OptionInputType(ListInputType(InputIndexType)), description = "desc here")
 
+  lazy val ServiceColumnOnServiceArgs = repo.allServices.map { service =>
+    lazy val ServiceColumnOnServiceType = InputObjectType(
+      "columnName",
+      description = "desc here",
+      fields = List(InputField("columnName", 
makeServiceColumnEnumTypeOnService(service)))
+    )
+
+    Argument(service.serviceName, OptionInputType(ServiceColumnOnServiceType))
+  }
+
+  def makeServiceColumnEnumTypeOnService(service: Service): EnumType[String] = 
{
+    val columns = service.serviceColumns(false).toList
+    EnumType(
+      s"${service.serviceName}_columns",
+      description = Option("desc here"),
+      values = dummyEnum +: columns.map { column =>
+        EnumValue(column.columnName, value = column.columnName)
+      }
+    )
+  }
+
   lazy val ServiceType = deriveObjectType[GraphRepository, Service](
     ObjectTypeName("Service"),
     ObjectTypeDescription("desc here"),
@@ -151,19 +172,19 @@ class S2ManagementType(repo: GraphRepository) {
 
 
   lazy val ServiceMutationResponseType = makeMutationResponseType[Service](
-    "CreateService",
+    "MutateService",
     "desc here",
     ServiceType
   )
 
   lazy val ServiceColumnMutationResponseType = 
makeMutationResponseType[ServiceColumn](
-    "CreateServiceColumn",
+    "MutateServiceColumn",
     "desc here",
     ServiceColumnType
   )
 
   lazy val LabelMutationResponseType = makeMutationResponseType[Label](
-    "CreateLabel",
+    "MutateLabelLabel",
     "desc here",
     LabelType
   )
@@ -244,6 +265,8 @@ class S2ManagementType(repo: GraphRepository) {
     * - createLabel
     * - ...
     */
+
+
   lazy val mutationFields: List[Field[GraphRepository, Any]] = List(
     Field("createService",
       ServiceMutationResponseType,
@@ -256,9 +279,9 @@ class S2ManagementType(repo: GraphRepository) {
       resolve = c => MutationResponse(c.ctx.createServiceColumn(c.args))
     ),
     Field("deleteServiceColumn",
-      ServiceColumnMutationResponseType,
-      arguments = List(ServiceNameRawArg, Argument("columnName", 
ServiceColumnListType)),
-      resolve = c => MutationResponse(c.ctx.deleteServiceColumn(c.args))
+      ListType(ServiceColumnMutationResponseType),
+      arguments = ServiceColumnOnServiceArgs,
+      resolve = c => c.ctx.deleteServiceColumn(c.args).map(MutationResponse(_))
     ),
     Field("createLabel",
       LabelMutationResponseType,

Reply via email to