From db1d9f5b15c2f083b11952b6ef2a1546be48c026 Mon Sep 17 00:00:00 2001 From: Rahul Somasunderam Date: Thu, 26 Oct 2023 10:09:31 -0700 Subject: [PATCH] feat: Improve IntelliJ support for json fields These usages in particular are useful when writing tests. --- .../kotlin/com/netflix/graphql/dgs/client/GraphQLResponse.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLResponse.kt b/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLResponse.kt index 8d55fca3f..d9465e53c 100644 --- a/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLResponse.kt +++ b/graphql-dgs-client/src/main/kotlin/com/netflix/graphql/dgs/client/GraphQLResponse.kt @@ -30,6 +30,7 @@ import com.jayway.jsonpath.Option import com.jayway.jsonpath.TypeRef import com.jayway.jsonpath.spi.json.JacksonJsonProvider import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider +import org.intellij.lang.annotations.Language import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -37,7 +38,7 @@ import org.slf4j.LoggerFactory * Representation of a GraphQL response, which may contain GraphQL errors. * This class gives convenient JSON parsing methods to get data out of the response. */ -data class GraphQLResponse(val json: String, val headers: Map>) { +data class GraphQLResponse(@Language("json") val json: String, val headers: Map>) { /** * A JsonPath DocumentContext. Typically, only used internally. @@ -51,7 +52,7 @@ data class GraphQLResponse(val json: String, val headers: Map = parsed.read("data") ?: emptyMap() val errors: List = parsed.read("errors", jsonTypeRef>()) ?: emptyList() - constructor(json: String) : this(json, emptyMap()) + constructor(@Language("json") json: String) : this(json, emptyMap()) /** * Deserialize data into the given class.