Skip to content
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

feat: Improve IntelliJ support for json fields #1683

Merged
merged 4 commits into from
Nov 8, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ 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

/**
* 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<String, List<String>>) {
data class GraphQLResponse(@Language("json") val json: String, val headers: Map<String, List<String>>) {

/**
* A JsonPath DocumentContext. Typically, only used internally.
Expand All @@ -51,7 +52,7 @@ data class GraphQLResponse(val json: String, val headers: Map<String, List<Strin
val data: Map<String, Any> = parsed.read("data") ?: emptyMap()
val errors: List<GraphQLError> = parsed.read("errors", jsonTypeRef<List<GraphQLError>>()) ?: emptyList()

constructor(json: String) : this(json, emptyMap())
constructor(@Language("json") json: String) : this(json, emptyMap())

/**
* Deserialize data into the given class.
Expand Down
Loading