Skip to content

Commit

Permalink
📚 update changelog and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nilwurtz committed Dec 8, 2023
1 parent 3ffcfec commit 98d6731
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 98d6731

Please sign in to comment.