-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
W-10674610: added GraphQL custom scalar parsing
- Loading branch information
1 parent
f802b8f
commit 25d22fc
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ql/shared/src/main/scala/amf/graphql/internal/spec/domain/GraphQLCustomScalarParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package amf.graphql.internal.spec.domain | ||
|
||
import amf.core.client.scala.model.DataType | ||
import amf.graphql.internal.spec.context.GraphQLWebApiContext | ||
import amf.graphql.internal.spec.parser.syntax.GraphQLASTParserHelper | ||
import amf.shapes.client.scala.model.domain.ScalarShape | ||
import org.mulesoft.antlrast.ast.Node | ||
|
||
class GraphQLCustomScalarParser(customScalarTypeDef: Node)(implicit val ctx: GraphQLWebApiContext) extends GraphQLASTParserHelper { | ||
val scalar: ScalarShape = ScalarShape(toAnnotations(customScalarTypeDef)) | ||
|
||
def parse(parentId: String): ScalarShape = { | ||
scalar.withDataType(DataType.String) | ||
parseNameAndFormat() | ||
scalar.adopted(parentId) | ||
scalar | ||
} | ||
|
||
private def parseNameAndFormat(): Unit = { | ||
val name= findName(customScalarTypeDef, "AnonymousScalar", "Missing scalar type name", scalar.id) | ||
scalar.withName(name) | ||
scalar.withFormat(name) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters