Skip to content

Refactor to remove build warnings #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ version = 1.0-SNAPSHOT
# build config
org.gradle.caching=true
org.gradle.parallel=true
kapt.incremental.apt=true
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = 2.0.0-SNAPSHOT
# build config
org.gradle.caching=true
org.gradle.parallel=true
kapt.incremental.apt=true

# See https://github.com/gradle/gradle/issues/11308
systemProp.org.gradle.internal.publish.checksums.insecure=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

@Suppress("Detekt.UnusedPrivateMember",
@Suppress(
"Detekt.UnusedPrivateMember",
"Detekt.FunctionOnlyReturningConstant",
"Detekt.LargeClass",
"Detekt.MethodOverloading")
"Detekt.MethodOverloading",
"UNUSED_PARAMETER",
"unused"
)
class ToSchemaTest {

@Test
Expand Down Expand Up @@ -452,11 +456,11 @@ class ToSchemaTest {
}

class QueryWithJavaClass {
fun query(): java.net.CookieManager? = CookieManager()
fun query(): CookieManager? = CookieManager()
}

class QueryWithListOfJavaClass {
fun listQuery(): List<java.net.CookieManager> = listOf(CookieManager())
fun listQuery(): List<CookieManager> = listOf(CookieManager())
}

class QueryWithConflictingTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ import org.springframework.web.reactive.function.server.buildAndAwait
import org.springframework.web.reactive.function.server.coRouter
import org.springframework.web.reactive.function.server.json

internal const val REQUEST_PARAM_QUERY = "query"
internal const val REQUEST_PARAM_OPERATION_NAME = "operationName"
internal const val REQUEST_PARAM_VARIABLES = "variables"
internal val graphQLMediaType = MediaType("application", "graphql")

/**
* Default route configuration for GraphQL service and SDL service endpoints.
*/
Expand All @@ -45,7 +50,6 @@ class RoutesConfiguration(
private val queryHandler: QueryHandler,
private val objectMapper: ObjectMapper
) {
private val graphQLMediaType: MediaType = MediaType("application", "graphql")
private val mapTypeReference: MapType = TypeFactory.defaultInstance().constructMapType(HashMap::class.java, String::class.java, Any::class.java)

@Bean
Expand Down Expand Up @@ -84,10 +88,10 @@ class RoutesConfiguration(
// https://github.com/FasterXML/jackson-module-kotlin/issues/221
@Suppress("BlockingMethodInNonBlockingContext")
private suspend fun createGraphQLRequest(serverRequest: ServerRequest): GraphQLRequest? = when {
serverRequest.queryParam("query").isPresent -> {
val query = serverRequest.queryParam("query").get()
val operationName: String? = serverRequest.queryParam("operationName").orElseGet { null }
val variables: String? = serverRequest.queryParam("variables").orElseGet { null }
serverRequest.queryParam(REQUEST_PARAM_QUERY).isPresent -> {
val query = serverRequest.queryParam(REQUEST_PARAM_QUERY).get()
val operationName: String? = serverRequest.queryParam(REQUEST_PARAM_OPERATION_NAME).orElseGet { null }
val variables: String? = serverRequest.queryParam(REQUEST_PARAM_VARIABLES).orElseGet { null }
val graphQLVariables: Map<String, Any>? = variables?.let {
objectMapper.readValue(it, mapTypeReference)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class FederationConfigurationTest {
)
}

@Suppress("unused")
class FederatedQuery : Query {
fun widget(): Widget = Widget(1, "hello")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class SubscriptionConfigurationTest {
fun query(): String = "hello!"
}

@Suppress("unused")
class SimpleSubscription : Subscription {
fun ticker(): Flux<Int> = Flux.range(1, 5)
.delayElements(Duration.ofMillis(100))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class InstrumentationIT(@Autowired private val testClient: WebTestClient) {
fun secondInstrumentation(): Instrumentation = OrderedInstrumentation(DEFAULT_INSTRUMENTATION_ORDER + 1, atomicCounter)
}

@Suppress("unused")
class BasicQuery : Query {
fun helloWorld(name: String) = "Hello $name!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package com.expediagroup.graphql.spring.routes

import com.expediagroup.graphql.annotations.GraphQLContext
import com.expediagroup.graphql.spring.REQUEST_PARAM_OPERATION_NAME
import com.expediagroup.graphql.spring.REQUEST_PARAM_QUERY
import com.expediagroup.graphql.spring.REQUEST_PARAM_VARIABLES
import com.expediagroup.graphql.spring.execution.GraphQLContextFactory
import com.expediagroup.graphql.spring.graphQLMediaType
import com.expediagroup.graphql.spring.model.GraphQLRequest
import com.expediagroup.graphql.spring.operations.Query
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
Expand Down Expand Up @@ -124,7 +128,7 @@ class RouteConfigurationIT(@Autowired private val testClient: WebTestClient) {
testClient.get()
.uri { builder ->
builder.path("/graphql")
.queryParam("query", "{query}")
.queryParam(REQUEST_PARAM_QUERY, "{query}")
.build(query)
}
.exchange()
Expand All @@ -139,9 +143,9 @@ class RouteConfigurationIT(@Autowired private val testClient: WebTestClient) {
testClient.get()
.uri { builder ->
builder.path("/graphql")
.queryParam("query", "{query}")
.queryParam("variables", "{variables}")
.queryParam("operationName", "{operationName}")
.queryParam(REQUEST_PARAM_QUERY, "{query}")
.queryParam(REQUEST_PARAM_VARIABLES, "{variables}")
.queryParam(REQUEST_PARAM_OPERATION_NAME, "{operationName}")
.build(query, jacksonObjectMapper().writeValueAsString(variables), operationName)
}
.exchange()
Expand All @@ -159,7 +163,7 @@ class RouteConfigurationIT(@Autowired private val testClient: WebTestClient) {
testClient.post()
.uri { builder ->
builder.path("/graphql")
.queryParam("query", "{query}")
.queryParam(REQUEST_PARAM_QUERY, "{query}")
.build("{ hello(name: \"POST query param\") }")
}
.accept(MediaType.APPLICATION_JSON)
Expand All @@ -174,7 +178,7 @@ class RouteConfigurationIT(@Autowired private val testClient: WebTestClient) {
testClient.post()
.uri("/graphql")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType("application", "graphql"))
.contentType(graphQLMediaType)
.bodyValue("query { hello(name: \"POST application/graphql\") }")
.exchange()
.verifyGraphQLRoute("Hello POST application/graphql!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.expediagroup.graphql.spring.routes

import com.expediagroup.graphql.spring.REQUEST_PARAM_QUERY
import com.expediagroup.graphql.spring.model.GraphQLRequest
import com.expediagroup.graphql.spring.model.SubscriptionOperationMessage
import com.expediagroup.graphql.spring.operations.Query
Expand All @@ -32,7 +33,6 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.MediaType
import org.springframework.test.web.reactive.server.WebTestClient
import org.springframework.web.reactive.socket.WebSocketMessage
import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
Expand Down Expand Up @@ -69,6 +69,7 @@ class SubscriptionRoutesConfigurationIT(
fun hello(name: String) = "Hello $name!"
}

@Suppress("unused")
class SimpleSubscription : Subscription {
fun getNumber(): Flux<Int> = Flux.just(42)
}
Expand Down Expand Up @@ -96,7 +97,7 @@ class SubscriptionRoutesConfigurationIT(
testClient.get()
.uri { builder ->
builder.path("/foo")
.queryParam("query", "{query}")
.queryParam(REQUEST_PARAM_QUERY, "{query}")
.build(query)
}
.exchange()
Expand All @@ -115,8 +116,7 @@ class SubscriptionRoutesConfigurationIT(
val sessionMono = client.execute(uri) { session ->
session.send(Mono.just(session.textMessage(objectMapper.writeValueAsString(message))))
.thenMany(session.receive()
.map(WebSocketMessage::getPayloadAsText)
.map { objectMapper.readValue<SubscriptionOperationMessage>(it) }
.map { objectMapper.readValue<SubscriptionOperationMessage>(it.payloadAsText) }
.map { objectMapper.writeValueAsString(it.payload) }
)
.subscribeWith(output)
Expand Down