From 98d67315428c6211e1ee79851b411e67e28890ce Mon Sep 17 00:00:00 2001 From: nilwurtz Date: Fri, 8 Dec 2023 22:44:59 +0900 Subject: [PATCH] :books: update changelog and fmt --- CHANGELOG.md | 1 + .../io/github/nilwurtz/GraphqlBodyMatcher.kt | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c5001b..932f2ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed +- Implemented `graphql-java`'s `AstSorter` and `AstComparator` for GraphQL query normalization. This integration significantly aligns the supported GraphQL features of our extension with those of `graphql-java`. ([#14](https://github.com/wiremock/wiremock-graphql-extension/pull/14) from @kyle-winkelman) ## [0.7.1] - 2023-11-25 ### Changed diff --git a/wiremock-graphql-extension/src/main/kotlin/io/github/nilwurtz/GraphqlBodyMatcher.kt b/wiremock-graphql-extension/src/main/kotlin/io/github/nilwurtz/GraphqlBodyMatcher.kt index d43b0bc..b726102 100644 --- a/wiremock-graphql-extension/src/main/kotlin/io/github/nilwurtz/GraphqlBodyMatcher.kt +++ b/wiremock-graphql-extension/src/main/kotlin/io/github/nilwurtz/GraphqlBodyMatcher.kt @@ -11,7 +11,6 @@ import graphql.language.Document import graphql.parser.Parser import io.github.nilwurtz.exceptions.InvalidJsonException import io.github.nilwurtz.exceptions.InvalidQueryException -import org.json.JSONException import org.json.JSONObject @@ -114,12 +113,21 @@ class GraphqlBodyMatcher() : RequestMatcherExtension() { val isQueryMatch = AstComparator.isEqual( requestJson.graphqlQueryDocument().sort(), - expectedRequestJson.graphqlQueryDocument().sort()) + expectedRequestJson.graphqlQueryDocument().sort() + ) val isVariablesMatch = requestJson.graphqlVariables().similar(expectedRequestJson.graphqlVariables()) return when { isQueryMatch && isVariablesMatch -> MatchResult.exactMatch() - else -> MatchResult.noMatch(SubEvent.info("Request query is not matched. Expected query: ${expectedRequestJson.getString("query")}")) + else -> MatchResult.noMatch( + SubEvent.info( + "Request query is not matched. Expected query: ${ + expectedRequestJson.getString( + "query" + ) + }" + ) + ) } } catch (e: Exception) { return MatchResult.noMatch(SubEvent.warning(e.message))