Skip to content

Commit

Permalink
Remove codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbakker committed Nov 1, 2024
1 parent 4e46136 commit acc1385
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 81 deletions.
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.*
plugins {
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.22"
id("com.netflix.dgs.codegen") version "6.3.0"
// id("com.netflix.dgs.codegen") version "6.3.0"
id("org.springframework.boot") version "3.3.5"
id("io.spring.dependency-management") version "1.1.6"
id("nebula.dependency-recommender") version "11.0.0"
Expand Down Expand Up @@ -57,6 +57,7 @@ dependencyManagement {
dependencies {
//implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:9.1.3"))
implementation("com.netflix.graphql.dgs:graphql-dgs-spring-graphql-starter")
implementation("com.netflix.graphql.dgs:graphql-dgs-client")
implementation("com.netflix.graphql.dgs:graphql-dgs-extended-scalars")
implementation("name.nkonev.multipart-spring-graphql:multipart-spring-graphql:1.1.4")
implementation("org.springframework.boot:spring-boot-starter-web:3.3.+")
Expand All @@ -79,10 +80,10 @@ dependencies {
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
}

tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
generateClientv2 = true
packageName = "com.example.demo.generated"
}
//tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
// generateClientv2 = true
// packageName = "com.example.demo.generated"
//}


tasks.withType<Test> {
Expand Down
99 changes: 99 additions & 0 deletions src/main/kotlin/com/example/demo/generated/DgsConstants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.example.demo.generated

import kotlin.String

public object DgsConstants {
public const val QUERY_TYPE: String = "Query"

public const val Mutation_TYPE: String = "Mutation"

public const val Subscription_TYPE: String = "Subscription"

public object QUERY {
public const val TYPE_NAME: String = "Query"

public const val Shows: String = "shows"

public object SHOWS_INPUT_ARGUMENT {
public const val TitleFilter: String = "titleFilter"
}
}

public object MUTATION {
public const val TYPE_NAME: String = "Mutation"

public const val AddReview: String = "addReview"

public const val AddArtwork: String = "addArtwork"

public object ADDREVIEW_INPUT_ARGUMENT {
public const val Review: String = "review"
}

public object ADDARTWORK_INPUT_ARGUMENT {
public const val ShowId: String = "showId"

public const val Upload: String = "upload"
}
}

public object SUBSCRIPTION {
public const val TYPE_NAME: String = "Subscription"

public const val ReviewAdded: String = "reviewAdded"

public object REVIEWADDED_INPUT_ARGUMENT {
public const val ShowId: String = "showId"
}
}

public object SHOW {
public const val TYPE_NAME: String = "Show"

public const val Id: String = "id"

public const val Title: String = "title"

public const val ReleaseYear: String = "releaseYear"

public const val Reviews: String = "reviews"

public const val Artwork: String = "artwork"

public object TITLE_INPUT_ARGUMENT {
public const val Format: String = "format"
}
}

public object REVIEW {
public const val TYPE_NAME: String = "Review"

public const val Username: String = "username"

public const val StarScore: String = "starScore"

public const val SubmittedDate: String = "submittedDate"
}

public object IMAGE {
public const val TYPE_NAME: String = "Image"

public const val Url: String = "url"
}

public object TITLEFORMAT {
public const val TYPE_NAME: String = "TitleFormat"

public const val Uppercase: String = "uppercase"
}

public object SUBMITTEDREVIEW {
public const val TYPE_NAME: String = "SubmittedReview"

public const val ShowId: String = "showId"

public const val Username: String = "username"

public const val StarScore: String = "starScore"
}
}
11 changes: 11 additions & 0 deletions src/main/kotlin/com/example/demo/generated/types/Image.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import kotlin.String

public data class Image(
@JsonProperty("url")
public val url: String? = null,
) {
public companion object
}
17 changes: 17 additions & 0 deletions src/main/kotlin/com/example/demo/generated/types/Review.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import java.time.OffsetDateTime
import kotlin.Int
import kotlin.String

public data class Review(
@JsonProperty("username")
public val username: String? = null,
@JsonProperty("starScore")
public val starScore: Int? = null,
@JsonProperty("submittedDate")
public val submittedDate: OffsetDateTime? = null,
) {
public companion object
}
21 changes: 21 additions & 0 deletions src/main/kotlin/com/example/demo/generated/types/Show.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import kotlin.Int
import kotlin.String
import kotlin.collections.List

public data class Show(
@JsonProperty("id")
public val id: Int,
@JsonProperty("title")
public val title: String,
@JsonProperty("releaseYear")
public val releaseYear: Int? = null,
@JsonProperty("reviews")
public val reviews: List<Review?>? = null,
@JsonProperty("artwork")
public val artwork: List<Image?>? = null,
) {
public companion object
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import kotlin.Int
import kotlin.String

public data class SubmittedReview(
@JsonProperty("showId")
public val showId: Int,
@JsonProperty("username")
public val username: String,
@JsonProperty("starScore")
public val starScore: Int,
) {
public companion object
}
10 changes: 10 additions & 0 deletions src/main/kotlin/com/example/demo/generated/types/Subscription.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty

public data class Subscription(
@JsonProperty("reviewAdded")
public val reviewAdded: Review? = null,
) {
public companion object
}
11 changes: 11 additions & 0 deletions src/main/kotlin/com/example/demo/generated/types/TitleFormat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.demo.generated.types

import com.fasterxml.jackson.`annotation`.JsonProperty
import kotlin.Boolean

public data class TitleFormat(
@JsonProperty("uppercase")
public val uppercase: Boolean? = null,
) {
public companion object
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@

package com.example.demo.datafetchers

import com.example.demo.generated.client.AddReviewGraphQLQuery
import com.example.demo.generated.client.AddReviewProjectionRoot
import com.example.demo.generated.types.Review
import com.example.demo.generated.types.SubmittedReview
import com.example.demo.scalars.DateTimeScalarRegistration
import com.example.demo.services.DefaultReviewsService
import com.example.demo.services.ShowsService
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.netflix.graphql.dgs.DgsQueryExecutor
import com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest
import com.netflix.graphql.dgs.scalars.UploadScalar
import graphql.ExecutionResult
import org.assertj.core.api.Assertions
import org.intellij.lang.annotations.Language
import org.junit.jupiter.api.Test
import org.reactivestreams.Publisher
import org.reactivestreams.Subscriber
Expand Down Expand Up @@ -84,16 +81,30 @@ class ReviewSubscriptionTest {
}

private fun addReview(): ExecutionResult {
val graphQLQueryRequest =
GraphQLQueryRequest(
AddReviewGraphQLQuery.Builder()
.review(SubmittedReview(1, "testuser", 5))
.build(),
AddReviewProjectionRoot<Nothing, Nothing>()
.username()
.starScore()
)
// val graphQLQueryRequest =
// GraphQLQueryRequest(
// AddReviewGraphQLQuery.Builder()
// .review(SubmittedReview(1, "testuser", 5))
// .build(),
// AddReviewProjectionRoot<Nothing, Nothing>()
// .username()
// .starScore()
// )

return dgsQueryExecutor.execute(graphQLQueryRequest.serialize())
@Language("GraphQL")
val query = """
mutation AddReview {
addReview(review: {
showId: 1
username: "testuser"
starScore: 5
}) {
username
starScore
}
}
""".trimIndent()

return dgsQueryExecutor.execute(query)
}
}
Loading

0 comments on commit acc1385

Please sign in to comment.