You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by da...@apache.org on 2018/07/13 06:26:39 UTC
[1/3] incubator-s2graph git commit: add toValidName
Repository: incubator-s2graph
Updated Branches:
refs/heads/master 08d6a3edd -> c1698e31e
add toValidName
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/8ff8c233
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/8ff8c233
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/8ff8c233
Branch: refs/heads/master
Commit: 8ff8c233e8a4f1194702c649bff3f5a99cb8273d
Parents: 08d6a3e
Author: daewon <da...@apache.org>
Authored: Tue Jul 10 14:20:37 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Tue Jul 10 14:20:37 2018 +0900
----------------------------------------------------------------------
.../s2graph/graphql/types/ManagementType.scala | 22 +++++------
.../apache/s2graph/graphql/types/S2Type.scala | 40 ++++++++++----------
.../apache/s2graph/graphql/types/package.scala | 28 +++++++++++---
3 files changed, 53 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/8ff8c233/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
index 1475280..1275ca7 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
@@ -68,8 +68,8 @@ class ManagementType(repo: GraphRepository) {
import org.apache.s2graph.graphql.types.StaticTypes._
lazy val serviceColumnOnServiceWithPropInputObjectFields = repo.services().map { service =>
- InputField(service.serviceName, OptionInputType(InputObjectType(
- s"Input_${service.serviceName}_ServiceColumn_Props",
+ InputField(service.serviceName.toValidName, OptionInputType(InputObjectType(
+ s"Input_${service.serviceName.toValidName}_ServiceColumn_Props",
description = "desc here",
fields = List(
InputField("columnName", makeServiceColumnEnumTypeOnService(service)),
@@ -79,8 +79,8 @@ class ManagementType(repo: GraphRepository) {
}
lazy val serviceColumnOnServiceInputObjectFields = repo.services().map { service =>
- InputField(service.serviceName, OptionInputType(InputObjectType(
- s"Input_${service.serviceName}_ServiceColumn",
+ InputField(service.serviceName.toValidName, OptionInputType(InputObjectType(
+ s"Input_${service.serviceName.toValidName}_ServiceColumn",
description = "desc here",
fields = List(
InputField("columnName", makeServiceColumnEnumTypeOnService(service))
@@ -94,14 +94,14 @@ class ManagementType(repo: GraphRepository) {
s"Enum_${service.serviceName}_ServiceColumn",
description = Option("desc here"),
values = dummyEnum +: columns.map { column =>
- EnumValue(column.columnName, value = column.columnName)
+ EnumValue(column.columnName.toValidName, value = column.columnName.toValidName)
}
)
}
lazy val labelPropsInputFields = repo.labels().map { label =>
- InputField(label.label, OptionInputType(InputObjectType(
- s"Input_${label.label}_props",
+ InputField(label.label.toValidName, OptionInputType(InputObjectType(
+ s"Input_${label.label.toValidName}_props",
description = "desc here",
fields = List(
InputField("props", ListInputType(InputPropType))
@@ -136,7 +136,7 @@ class ManagementType(repo: GraphRepository) {
description = Option("desc here"),
values =
dummyEnum +: repo.services().map { service =>
- EnumValue(service.serviceName, value = service.serviceName)
+ EnumValue(service.serviceName.toValidName, value = service.serviceName)
}
)
@@ -145,7 +145,7 @@ class ManagementType(repo: GraphRepository) {
description = Option("desc here"),
values =
dummyEnum +: repo.serviceColumns().map { serviceColumn =>
- EnumValue(serviceColumn.columnName, value = serviceColumn.columnName)
+ EnumValue(serviceColumn.columnName.toValidName, value = serviceColumn.columnName)
}
)
@@ -154,7 +154,7 @@ class ManagementType(repo: GraphRepository) {
description = Option("desc here"),
values =
dummyEnum +: repo.labels().map { label =>
- EnumValue(label.label, value = label.label)
+ EnumValue(label.label.toValidName, value = label.label)
}
)
@@ -222,7 +222,7 @@ class ManagementType(repo: GraphRepository) {
arguments = List(ServiceNameArg),
resolve = { c =>
c.argOpt[String]("name") match {
- case Some(name) => c.ctx.services().filter(_.serviceName == name)
+ case Some(name) => c.ctx.services().filter(_.serviceName.toValidName == name)
case None => c.ctx.services()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/8ff8c233/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 1324126..a18fc4e 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
@@ -72,24 +72,24 @@ object S2Type {
val inputFields = service.serviceColumns(false).map { serviceColumn =>
val idField = InputField("id", toScalarType(serviceColumn.columnType))
val propFields = serviceColumn.metasWithoutCache.filter(ColumnMeta.isValid).map { lm =>
- InputField(lm.name, OptionInputType(toScalarType(lm.dataType)))
+ InputField(lm.name.toValidName, OptionInputType(toScalarType(lm.dataType)))
}
val vertexMutateType = InputObjectType[Map[String, Any]](
- s"Input_${service.serviceName}_${serviceColumn.columnName}_vertex_mutate",
+ s"Input_${service.serviceName.toValidName}_${serviceColumn.columnName.toValidName}_vertex_mutate",
description = "desc here",
() => idField :: propFields
)
- InputField[Any](serviceColumn.columnName, OptionInputType(ListInputType(vertexMutateType)))
+ InputField[Any](serviceColumn.columnName.toValidName, OptionInputType(ListInputType(vertexMutateType)))
}
inputFields
}
def makeInputFieldsOnLabel(label: Label): Seq[InputField[Any]] = {
- val propFields = label.labelMetaSet.toList.map { lm =>
- InputField(lm.name, OptionInputType(toScalarType(lm.dataType)))
+ val propFields = label.labelMetaSet.toList.filterNot(_.name == "timestamp").map { lm =>
+ InputField(lm.name.toValidName, OptionInputType(toScalarType(lm.dataType)))
}
val labelFields = List(
@@ -112,7 +112,7 @@ object S2Type {
val inLabels = diffLabel.filter(l => column == l.tgtColumn).distinct.toList
val inOutLabels = sameLabel.filter(l => l.srcColumn == column && l.tgtColumn == column)
- lazy val columnFields = (reservedFields ++ columnMetasKv).map { case (k, v) => makeGraphElementField(k, v) }
+ lazy val columnFields = (reservedFields ++ columnMetasKv).map { case (k, v) => makeGraphElementField(k.toValidName, v) }
lazy val outLabelFields: List[Field[GraphRepository, Any]] = outLabels.map(l => makeLabelField("out", l, allLabels))
lazy val inLabelFields: List[Field[GraphRepository, Any]] = inLabels.map(l => makeLabelField("in", l, allLabels))
@@ -132,7 +132,7 @@ object S2Type {
() => fields[GraphRepository, Any](serviceColumnFields: _*)
)
- Field(column.columnName,
+ Field(column.columnName.toValidName,
ListType(ColumnType),
arguments = List(
Argument("id", OptionInputType(toScalarType(column.columnType))),
@@ -162,11 +162,11 @@ object S2Type {
val column = if (dir == "out") label.tgtColumn else label.srcColumn
lazy val labelFields: List[Field[GraphRepository, Any]] =
- (labelReserved ++ labelProps).map { case (k, v) => makeGraphElementField(k, v) }
+ (labelReserved ++ labelProps).map { case (k, v) => makeGraphElementField(k.toValidName, v) }
- lazy val labelPropField = wrapField(s"Label_${label.label}_props", "props", labelFields)
+ lazy val labelPropField = wrapField(s"Label_${label.label.toValidName}_props", "props", labelFields)
- lazy val labelColumnType = ObjectType(s"Label_${label.label}_${column.columnName}",
+ lazy val labelColumnType = ObjectType(s"Label_${label.label.toValidName}_${column.columnName.toValidName}",
() => makeServiceColumnFields(column, allLabels)
)
@@ -178,7 +178,7 @@ object S2Type {
})
lazy val EdgeType = ObjectType(
- s"Label_${label.label}_${column.columnName}_${dir}",
+ s"Label_${label.label.toValidName}_${column.columnName.toValidName}_${dir}",
() => fields[GraphRepository, Any](
List(serviceColumnField, labelPropField) ++ labelFields.filterNot(_.name == column.columnName): _*)
)
@@ -190,11 +190,11 @@ object S2Type {
}
val idxNames = label.indices.map { idx =>
- EnumValue(idx.name, value = idx.name)
+ EnumValue(idx.name.toValidName, value = idx.name.toValidName)
}
val indexEnumType = EnumType(
- s"Label_Index_${label.label}",
+ s"Label_Index_${label.label.toValidName}",
description = Option("desc here"),
values = idxNames
)
@@ -207,7 +207,7 @@ object S2Type {
)
lazy val edgeTypeField: Field[GraphRepository, Any] = Field(
- s"${label.label}",
+ s"${label.label.toValidName}",
ListType(EdgeType),
arguments = dirArgs ++ paramArgs,
description = Some("fetch edges"),
@@ -239,12 +239,12 @@ class S2Type(repo: GraphRepository) {
lazy val serviceFields = DummyObjectTypeField :: makeServiceField(service, repo.labels())
lazy val ServiceType = ObjectType(
- s"Service_${service.serviceName}",
+ s"Service_${service.serviceName.toValidName}",
fields[GraphRepository, Any](serviceFields: _*)
)
Field(
- service.serviceName,
+ service.serviceName.toValidName,
ServiceType,
description = Some(s"serviceName: ${service.serviceName}"),
resolve = _ => service
@@ -259,10 +259,10 @@ class S2Type(repo: GraphRepository) {
val serviceFields = DummyInputField +: makeInputFieldsOnService(service)
val ServiceInputType = InputObjectType[List[AddVertexParam]](
- s"Input_vertex_${service.serviceName}_param",
+ s"Input_vertex_${service.serviceName.toValidName}_param",
() => serviceFields.toList
)
- Argument(service.serviceName, OptionInputType(ServiceInputType))
+ Argument(service.serviceName.toValidName, OptionInputType(ServiceInputType))
}
serviceArguments
@@ -272,11 +272,11 @@ class S2Type(repo: GraphRepository) {
val labelArguments = repo.labels().map { label =>
val labelFields = DummyInputField +: makeInputFieldsOnLabel(label)
val labelInputType = InputObjectType[AddEdgeParam](
- s"Input_label_${label.label}_param",
+ s"Input_label_${label.label.toValidName}_param",
() => labelFields.toList
)
- Argument(label.label, OptionInputType(ListInputType(labelInputType)))
+ Argument(label.label.toValidName, OptionInputType(ListInputType(labelInputType)))
}
labelArguments
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/8ff8c233/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/package.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/package.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/package.scala
index 1f43edd..bea8bc4 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/package.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/package.scala
@@ -31,12 +31,28 @@ package object types {
def toScalarType(from: String): ScalarType[_] = from match {
case "string" => StringType
- case "int" => IntType
- case "integer" => IntType
+ case "int" | "integer" => IntType
case "long" => LongType
- case "float" => FloatType
- case "double" => FloatType
- case "boolean" => BooleanType
- case "bool" => BooleanType
+ case "float" | "double" => FloatType
+ case "bool" | "boolean" => BooleanType
}
+
+ val validateRegEx = "/^[_a-zA-Z][_a-zA-Z0-9]*$/.".r
+
+ val ints = (0 to 9).map(_.toString).toSet
+
+ implicit class StringOps(val s: String) extends AnyVal {
+ def toValidName: String = {
+ val newS = s
+ .replaceAll("-", "_HYPHEN_")
+ .replaceAll("-", "_DASH_")
+ .replaceAll(":", "_COLON_")
+ .replaceAll(" ", "_SPACE_")
+ .trim
+
+ if (ints.contains(newS.head.toString)) s"NUMBER_${newS}"
+ else newS
+ }
+ }
+
}
[3/3] incubator-s2graph git commit: [S2GRAPH-231] Change the GraphQL
type name to a valid string.
Posted by da...@apache.org.
[S2GRAPH-231] Change the GraphQL type name to a valid string.
JIRA:
[S2GRAPH-231] https://issues.apache.org/jira/browse/S2GRAPH-231
Pull Request:
Closes #180
Author
daewon <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/c1698e31
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/c1698e31
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/c1698e31
Branch: refs/heads/master
Commit: c1698e31e14be34bcdc7230ed7a8e68ab5ec6d19
Parents: 8de8f55
Author: daewon <da...@apache.org>
Authored: Fri Jul 13 15:26:13 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Jul 13 15:26:13 2018 +0900
----------------------------------------------------------------------
CHANGES | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/c1698e31/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index da32f18..0595ad5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -83,6 +83,7 @@ Release Notes - S2Graph - Version 0.2.0
* [S2GRAPH-214] - Add REAME for movielens examples
* [S2GRAPH-216] - Provide a transform directive in the GraphQL query result.
* [S2GRAPH-221] - Unify configurations for bulk and mutate in S2GraphSink.
+ * [S2GRAPH-231] - Change the GraphQL type name to a valid string.
** New Feature
* [S2GRAPH-123] - Support different index on out/in direction.
[2/3] incubator-s2graph git commit: reTest ci
Posted by da...@apache.org.
reTest ci
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/8de8f557
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/8de8f557
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/8de8f557
Branch: refs/heads/master
Commit: 8de8f5571569db72265a5e600a3b41c4c01e3655
Parents: 8ff8c23
Author: daewon <da...@apache.org>
Authored: Fri Jul 13 14:55:52 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Fri Jul 13 14:55:52 2018 +0900
----------------------------------------------------------------------
.../scala/org/apache/s2graph/graphql/types/ManagementType.scala | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/8de8f557/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
----------------------------------------------------------------------
diff --git a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
index 1275ca7..9baec93 100644
--- a/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
+++ b/s2graphql/src/main/scala/org/apache/s2graph/graphql/types/ManagementType.scala
@@ -17,6 +17,7 @@
* under the License.
*/
+
package org.apache.s2graph.graphql.types
import org.apache.s2graph.core.schema._