-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Is your feature request related to a problem? Please describe.
Initially, it will be implemented by replacing parts of the syntax directly and using java collections as much as possible and java annotations (although annotations are not necessary for Scala). I will do it.
Of course, all the features on Java will be preserved. For example, builder class , javadoc and entity classes (it is not recommended to use var in functional lang , but in this pr varis default, and val is generated if immutableModels is true).
One of the problems that i can think of at present is that i can't build the basic types of Java in scala code, because Int in scala is equivalent to Java int(other primitive type), and Int itself is an object (optimized, so it still better than integer
), but i will use Integer directly at present.(can use putCustomTypeMappingIfAbsent to set scala type)
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
If accept issue please assign to me, I have roughly worked out the template and the basic implementation, and will writegithub.graphqlsunit test.
This is example(maybe have some errors). There are a lot of annotations and var in this example, which is not a good style in Scala, but it can only be implemented this time:
- input
package com.github.graphql
import java.util.StringJoiner
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
case class AcceptTopicSuggestionInput(
var clientMutationId: String,
@javax.validation.constraints.NotNull
var name: String,
@javax.validation.constraints.NotNull
var repositoryId: String
) {
override def toString(): String = {
val joiner = new StringJoiner(", ", "{ ", " }")
if (clientMutationId != null) {
joiner.add(s"clientMutationId: \"$clientMutationId\"")
}
if (name != null) {
joiner.add(s"name: \"$name\"")
}
if (repositoryId != null) {
joiner.add(s"repositoryId: \"$repositoryId\"")
}
joiner.toString()
}
}
object AcceptTopicSuggestionInput {
def builder(): AcceptTopicSuggestionInput.Builder = new Builder()
class Builder {
private var clientMutationId: String = _
private var name: String = _
private var repositoryId: String = _
def setClientMutationId(clientMutationId: String): Builder = {
this.clientMutationId = clientMutationId
this
}
def setName(name: String): Builder = {
this.name = name
this
}
def setRepositoryId(repositoryId: String): Builder = {
this.repositoryId = repositoryId
this
}
def build(): AcceptTopicSuggestionInput = new AcceptTopicSuggestionInput(clientMutationId, name, repositoryId)
}
}- resolver
package com.github.graphql
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
trait AcceptTopicSuggestionMutationResolver {
@throws[Exception]
def acceptTopicSuggestion(input: AcceptTopicSuggestionInput): AcceptTopicSuggestionPayload
}- type
package com.github.graphql
import java.util.StringJoiner
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
case class AcceptTopicSuggestionPayload(
var clientMutationId: String,
var topic: Topic
) {
override def toString(): String = {
val joiner = new StringJoiner(", ", "{ ", " }")
if (clientMutationId != null) {
joiner.add(s"clientMutationId: \"$clientMutationId\"")
}
if (topic != null) {
joiner.add(s"topic: $topic")
}
joiner.toString()
}
}
object AcceptTopicSuggestionPayload {
def builder(): AcceptTopicSuggestionPayload.Builder = new Builder()
class Builder {
private var clientMutationId: String = _
private var topic: Topic = _
def setClientMutationId(clientMutationId: String): Builder = {
this.clientMutationId = clientMutationId
this
}
def setTopic(topic: Topic): Builder = {
this.topic = topic
this
}
def build(): AcceptTopicSuggestionPayload = new AcceptTopicSuggestionPayload(clientMutationId, topic)
}
}- interface
package com.github.graphql
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
trait Actor {
@javax.validation.constraints.NotNull
def getAvatarUrl(): String
@javax.validation.constraints.NotNull
def getLogin(): String
@javax.validation.constraints.NotNull
def getResourcePath(): String
@javax.validation.constraints.NotNull
def getUrl(): String
}5.type extend
package com.github.graphql
import java.util.StringJoiner
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
case class BranchProtectionRule(
@javax.validation.constraints.NotNull
var branchProtectionRuleConflicts: BranchProtectionRuleConflictConnection,
var creator: Actor,
var databaseId: Integer,
var dismissesStaleReviews: boolean,
@javax.validation.constraints.NotNull
var id: String,
var isAdminEnforced: boolean,
@javax.validation.constraints.NotNull
var matchingRefs: RefConnection,
@javax.validation.constraints.NotNull
var pattern: String,
@javax.validation.constraints.NotNull
var pushAllowances: PushAllowanceConnection,
var repository: Repository,
var requiredApprovingReviewCount: Integer,
var requiredStatusCheckContexts: java.util.List[String],
var requiresApprovingReviews: boolean,
var requiresCodeOwnerReviews: boolean,
var requiresCommitSignatures: boolean,
var requiresStatusChecks: boolean,
var requiresStrictStatusChecks: boolean,
var restrictsPushes: boolean,
var restrictsReviewDismissals: boolean,
@javax.validation.constraints.NotNull
var reviewDismissalAllowances: ReviewDismissalAllowanceConnection
) extends Node {
override def toString(): String = {
val joiner = new StringJoiner(", ", "{ ", " }")
if (branchProtectionRuleConflicts != null) {
joiner.add(s"branchProtectionRuleConflicts: $branchProtectionRuleConflicts")
}
if (creator != null) {
joiner.add(s"creator: $creator")
}
if (databaseId != null) {
joiner.add(s"databaseId: $databaseId")
}
joiner.add(s"dismissesStaleReviews: $dismissesStaleReviews")
if (id != null) {
joiner.add(s"id: \"$id\"")
}
joiner.add(s"isAdminEnforced: $isAdminEnforced")
if (matchingRefs != null) {
joiner.add(s"matchingRefs: $matchingRefs")
}
if (pattern != null) {
joiner.add(s"pattern: \"$pattern\"")
}
if (pushAllowances != null) {
joiner.add(s"pushAllowances: $pushAllowances")
}
if (repository != null) {
joiner.add(s"repository: $repository")
}
if (requiredApprovingReviewCount != null) {
joiner.add(s"requiredApprovingReviewCount: $requiredApprovingReviewCount")
}
if (requiredStatusCheckContexts != null) {
joiner.add(s"requiredStatusCheckContexts: $requiredStatusCheckContexts")
}
joiner.add(s"requiresApprovingReviews: $requiresApprovingReviews")
joiner.add(s"requiresCodeOwnerReviews: $requiresCodeOwnerReviews")
joiner.add(s"requiresCommitSignatures: $requiresCommitSignatures")
joiner.add(s"requiresStatusChecks: $requiresStatusChecks")
joiner.add(s"requiresStrictStatusChecks: $requiresStrictStatusChecks")
joiner.add(s"restrictsPushes: $restrictsPushes")
joiner.add(s"restrictsReviewDismissals: $restrictsReviewDismissals")
if (reviewDismissalAllowances != null) {
joiner.add(s"reviewDismissalAllowances: $reviewDismissalAllowances")
}
joiner.toString()
}
}
object BranchProtectionRule {
def builder(): BranchProtectionRule.Builder = new Builder()
class Builder {
private var branchProtectionRuleConflicts: BranchProtectionRuleConflictConnection = _
private var creator: Actor = _
private var databaseId: Integer = _
private var dismissesStaleReviews: boolean = _
private var id: String = _
private var isAdminEnforced: boolean = _
private var matchingRefs: RefConnection = _
private var pattern: String = _
private var pushAllowances: PushAllowanceConnection = _
private var repository: Repository = _
private var requiredApprovingReviewCount: Integer = _
private var requiredStatusCheckContexts: java.util.List[String] = _
private var requiresApprovingReviews: boolean = _
private var requiresCodeOwnerReviews: boolean = _
private var requiresCommitSignatures: boolean = _
private var requiresStatusChecks: boolean = _
private var requiresStrictStatusChecks: boolean = _
private var restrictsPushes: boolean = _
private var restrictsReviewDismissals: boolean = _
private var reviewDismissalAllowances: ReviewDismissalAllowanceConnection = _
def setBranchProtectionRuleConflicts(branchProtectionRuleConflicts: BranchProtectionRuleConflictConnection): Builder = {
this.branchProtectionRuleConflicts = branchProtectionRuleConflicts
this
}
def setCreator(creator: Actor): Builder = {
this.creator = creator
this
}
def setDatabaseId(databaseId: Integer): Builder = {
this.databaseId = databaseId
this
}
def setDismissesStaleReviews(dismissesStaleReviews: boolean): Builder = {
this.dismissesStaleReviews = dismissesStaleReviews
this
}
def setId(id: String): Builder = {
this.id = id
this
}
def setIsAdminEnforced(isAdminEnforced: boolean): Builder = {
this.isAdminEnforced = isAdminEnforced
this
}
def setMatchingRefs(matchingRefs: RefConnection): Builder = {
this.matchingRefs = matchingRefs
this
}
def setPattern(pattern: String): Builder = {
this.pattern = pattern
this
}
def setPushAllowances(pushAllowances: PushAllowanceConnection): Builder = {
this.pushAllowances = pushAllowances
this
}
def setRepository(repository: Repository): Builder = {
this.repository = repository
this
}
def setRequiredApprovingReviewCount(requiredApprovingReviewCount: Integer): Builder = {
this.requiredApprovingReviewCount = requiredApprovingReviewCount
this
}
def setRequiredStatusCheckContexts(requiredStatusCheckContexts: java.util.List[String]): Builder = {
this.requiredStatusCheckContexts = requiredStatusCheckContexts
this
}
def setRequiresApprovingReviews(requiresApprovingReviews: boolean): Builder = {
this.requiresApprovingReviews = requiresApprovingReviews
this
}
def setRequiresCodeOwnerReviews(requiresCodeOwnerReviews: boolean): Builder = {
this.requiresCodeOwnerReviews = requiresCodeOwnerReviews
this
}
def setRequiresCommitSignatures(requiresCommitSignatures: boolean): Builder = {
this.requiresCommitSignatures = requiresCommitSignatures
this
}
def setRequiresStatusChecks(requiresStatusChecks: boolean): Builder = {
this.requiresStatusChecks = requiresStatusChecks
this
}
def setRequiresStrictStatusChecks(requiresStrictStatusChecks: boolean): Builder = {
this.requiresStrictStatusChecks = requiresStrictStatusChecks
this
}
def setRestrictsPushes(restrictsPushes: boolean): Builder = {
this.restrictsPushes = restrictsPushes
this
}
def setRestrictsReviewDismissals(restrictsReviewDismissals: boolean): Builder = {
this.restrictsReviewDismissals = restrictsReviewDismissals
this
}
def setReviewDismissalAllowances(reviewDismissalAllowances: ReviewDismissalAllowanceConnection): Builder = {
this.reviewDismissalAllowances = reviewDismissalAllowances
this
}
def build(): BranchProtectionRule = new BranchProtectionRule(branchProtectionRuleConflicts, creator, databaseId, dismissesStaleReviews, id, isAdminEnforced, matchingRefs, pattern, pushAllowances, repository, requiredApprovingReviewCount, requiredStatusCheckContexts, requiresApprovingReviews, requiresCodeOwnerReviews, requiresCommitSignatures, requiresStatusChecks, requiresStrictStatusChecks, restrictsPushes, restrictsReviewDismissals, reviewDismissalAllowances)
}
}- request
package com.github.graphql
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperation
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLOperationRequest
import java.util.{ LinkedHashMap => JLinkedHashMap }
import java.util.{ Map => JMap }
import java.util.Objects
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
class AcceptTopicSuggestionMutationRequest extends GraphQLOperationRequest {
private var alias: String = _
private final lazy val input = new JLinkedHashMap[String, AnyRef]()
def this(alias: String) {
this()
this.alias = alias
}
def setInput(input: AcceptTopicSuggestionInput ): Unit = {
this.input.put("input", input)
}
override def getOperationType(): GraphQLOperation = AcceptTopicSuggestionMutationRequest.OPERATION_TYPE
override def getOperationName(): String = AcceptTopicSuggestionMutationRequest.OPERATION_NAME
override def getAlias(): String = if (alias != null) alias else AcceptTopicSuggestionMutationRequest.OPERATION_NAME
override def getInput(): JMap[String, AnyRef] = input
override def toString(): String = Objects.toString(input)
}
object AcceptTopicSuggestionMutationRequest {
final val OPERATION_NAME: String = "acceptTopicSuggestion"
final val OPERATION_TYPE: GraphQLOperation = GraphQLOperation.MUTATION
def builder(): Builder = new Builder()
class Builder {
private var $alias: String = _
private var input: AcceptTopicSuggestionInput = _
def alias(alias: String): Builder = {
this.$alias = alias
this
}
def setInput(input: AcceptTopicSuggestionInput ): Builder = {
this.input = input
this
}
def build(): AcceptTopicSuggestionMutationRequest = {
val obj = new AcceptTopicSuggestionMutationRequest($alias)
obj.setInput(input)
obj
}
}
}- response
package com.github.graphql
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResult
import java.util.{ Map => JMap }
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
class AcceptTopicSuggestionMutationResponse extends GraphQLResult[Map[String, AcceptTopicSuggestionPayload]] {
def acceptTopicSuggestion(): AcceptTopicSuggestionPayload = {
val data: JMap[String, AcceptTopicSuggestionPayload] = getData()
if (data != null) data.get(AcceptTopicSuggestionMutationResponse.OPERATION_NAME) else null
}
}
object AcceptTopicSuggestionMutationResponse {
private final val OPERATION_NAME: String = "acceptTopicSuggestion"
}- projection
package com.github.graphql
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseField
import com.kobylynskyi.graphql.codegen.model.graphql.GraphQLResponseProjection
/**
* Response projection for AcceptTopicSuggestionPayload
*/
@javax.annotation.Generated(
value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
date = "2020-12-31T23:59:59-0500"
)
class AcceptTopicSuggestionPayloadResponseProjection extends GraphQLResponseProjection {
override def all$(): AcceptTopicSuggestionPayloadResponseProjection = all$(3)
override def all$(int maxDepth): AcceptTopicSuggestionPayloadResponseProjection = {
this.clientMutationId()
if (projectionDepthOnFields.getOrDefault("AcceptTopicSuggestionPayloadResponseProjection.TopicResponseProjection.topic", 0) <= maxDepth) {
projectionDepthOnFields.put("AcceptTopicSuggestionPayloadResponseProjection.TopicResponseProjection.topic", projectionDepthOnFields.getOrDefault("AcceptTopicSuggestionPayloadResponseProjection.TopicResponseProjection.topic", 0) + 1)
this.topic(new TopicResponseProjection().all$(maxDepth - projectionDepthOnFields.getOrDefault("AcceptTopicSuggestionPayloadResponseProjection.TopicResponseProjection.topic", 0)))
}
this.typename()
this
}
def clientMutationId(): AcceptTopicSuggestionPayloadResponseProjection {
clientMutationId(null)
}
def clientMutationId(alias: String): AcceptTopicSuggestionPayloadResponseProjection = {
fields.add(new GraphQLResponseField("clientMutationId").alias(alias))
this
}
def topic(subProjection: TopicResponseProjection ): AcceptTopicSuggestionPayloadResponseProjection {
topic(null, subProjection)
}
def topic(alias: String, subProjection: TopicResponseProjection): AcceptTopicSuggestionPayloadResponseProjection = {
fields.add(new GraphQLResponseField("topic").alias(alias).projection(subProjection))
this
}
def typename(): AcceptTopicSuggestionPayloadResponseProjection {
typename(null)
}
def typename(alias: String): AcceptTopicSuggestionPayloadResponseProjection = {
fields.add(new GraphQLResponseField("__typename").alias(alias))
this
}
}