Skip to content

Commit f726096

Browse files
committed
chore(graphkt-example): replaced deprecated usages
1 parent e0d9518 commit f726096

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

graphkt-example/src/jvmMain/kotlin/example.kt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import io.ktor.server.websocket.*
1111
import kotlinx.coroutines.flow.MutableSharedFlow
1212
import kotlinx.coroutines.flow.filter
1313
import org.cufy.graphkt.java.`graphql-java`
14-
import org.cufy.graphkt.ktor.*
14+
import org.cufy.graphkt.ktor.graphql
15+
import org.cufy.graphkt.ktor.graphqlPlayground
16+
import org.cufy.graphkt.ktor.schema
1517
import org.cufy.graphkt.schema.*
1618
import org.slf4j.event.Level
1719
import java.time.Duration
@@ -22,8 +24,8 @@ class CustomObject(val name: String, val value: String)
2224
val CustomFlow = MutableSharedFlow<CustomObject>()
2325

2426
val CustomScalarType = GraphQLScalarType<CustomScalar> {
25-
name("CustomScalar")
26-
description { "An example of a custom scalar." }
27+
name = "CustomScalar"
28+
description = "An example of a custom scalar."
2729
encode { GraphQLString(it.value) }
2830
decode {
2931
require(it is GraphQLString) { "Expected GraphQLString but got ${it::class.simpleName}" }
@@ -32,31 +34,31 @@ val CustomScalarType = GraphQLScalarType<CustomScalar> {
3234
}
3335

3436
object CustomObjectType : GraphQLObjectClass<CustomObject>({
35-
name("Custom")
36-
description { "An example of a custom object type." }
37+
name = "Custom"
38+
description = "An example of a custom object type."
3739
field(CustomObject::name) {
40+
description = "The name of the object."
3841
type { GraphQLStringType }
39-
description { "The name of the object." }
4042
}
4143
field(CustomObject::value) {
44+
description = "The value of the object."
4245
type { GraphQLStringType }
43-
description { "The value of the object." }
4446
}
4547
field("this") {
48+
description = "This"
4649
type { CustomObjectType }
47-
description { "This" }
4850
get { instance }
4951
}
5052
field("copycatOfThis") {
53+
description = "This but as the copycat version."
5154
type { CustomObjectTypeCopyCat }
52-
description { "This but as the copycat version." }
5355
get { instance }
5456
}
5557
})
5658

5759
object CustomObjectTypeCopyCat : GraphQLObjectClass<CustomObject>({
58-
name("CustomCopyCat")
59-
description { "An example of a custom object type copying another type." }
60+
name = "CustomCopyCat"
61+
description = "An example of a custom object type copying another type."
6062

6163
directives += CustomObjectType.directives
6264
interfaces += CustomObjectType.interfaces
@@ -88,12 +90,11 @@ fun Application.myApplicationModule() {
8890
masking = false
8991
}
9092

91-
playground()
93+
graphqlPlayground()
9294
// graphiql()
9395
graphql {
9496
`graphql-java`
95-
96-
enableGraphQLS()
97+
graphqls = "/graphqls"
9798

9899
schema {
99100
query {
@@ -112,12 +113,12 @@ fun Application.myApplicationModule() {
112113
@GraphQLDsl
113114
fun GraphQLRoute<Unit>.queries() {
114115
field("cat") {
116+
description = "Return the input"
115117
type { CustomScalarType }
116-
description { "Return the input" }
117118

118119
val valueArg = argument("value") {
120+
description = "The value to return"
119121
type { CustomScalarType }
120-
description { "The value to return" }
121122
}
122123

123124
get { valueArg() }
@@ -130,12 +131,12 @@ fun GraphQLRoute<Unit>.mutations() {
130131
type { GraphQLVoidType }
131132

132133
val nameArg = argument("name") {
134+
description = "The name to be associated with the emitted value."
133135
type { GraphQLStringType }
134-
description { "The name to be associated with the emitted value." }
135136
}
136137
val valueArg = argument("value") {
138+
description = "The value to be emitted"
137139
type { GraphQLStringType }
138-
description { "The value to be emitted" }
139140
}
140141

141142
get {
@@ -153,8 +154,8 @@ fun GraphQLRoute<Unit>.subscriptions() {
153154
type { CustomObjectType }
154155

155156
val nameArg = argument("name") {
157+
description = "The name to filter the messages by."
156158
type { GraphQLStringType }
157-
description { "The name to filter the messages by." }
158159
}
159160

160161
getFlow {

0 commit comments

Comments
 (0)