Skip to content

Commit

Permalink
🚀 v0.8.2 and some documents format
Browse files Browse the repository at this point in the history
  • Loading branch information
nilwurtz committed Jan 4, 2024
1 parent 047d74c commit b581c26
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 28 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,119 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

### Changed

## [0.8.2] - 2024-01-04

### Added

- Added `operationName` parameter ([#18](https://github.com/wiremock/wiremock-graphql-extension/pull/18) from @kyle-winkelman)
- Added `GraphqlBodyMatcher.parameters` method which can use create `Parameters` easily ([#18](https://github.com/wiremock/wiremock-graphql-extension/pull/18) from @kyle-winkelman)

### Changed

- Remove `org.json:json` dependency in favor of reusing `com.github.tomakehurst.wiremock.common.Json` ([#18](https://github.com/wiremock/wiremock-graphql-extension/pull/18) from @kyle-winkelman)
- Deprecate `withRequestJson` and `withRequest` in favor of `parameters` ([#18](https://github.com/wiremock/wiremock-graphql-extension/pull/18) from @kyle-winkelman)

## [0.8.1] - 2023-12-12

### Changed

- Added `@JvmStatic` annotation to `GraphqlBodyMatcher.Companion.withRequest` method to allow Java clients to use the method without `Companion`. ([#16](https://github.com/wiremock/wiremock-graphql-extension/pull/16) from @kyle-winkelman)

## [0.8.0] - 2023-12-08

### 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

- Update dev dependencies (kotlin, mockk, junit, testcontainers)

### Fixed

- Improved handling of newline characters in JSON strings. Newline characters are now removed to prevent parsing errors (`JSONException: Unterminated string`) when processing JSON data. This change ensures that JSON strings with embedded newlines are handled correctly by the `String.toJSONObject()` method. ([#11](https://github.com/wiremock/wiremock-graphql-extension/issues/11))

## [0.7.0] - 2023-09-27

### Changed

- Throws `InvalidQueryException` and `InvalidJsonException` when `withRequest` is called.
- When `match` method is called, it will not throw any exception if the request is invalid.

## [0.6.2] - 2023-09-08

### Added

- Added `withRequest` method which can used easily when using remote wiremock server.

## [0.6.1] - 2023-08-31

### Changed

- Update target jvmVersion 1.8 -> 11
- Update graphql-java 20.2 -> 21.0
- Update json 20230227 -> 20230618
- Update dev dependencies (kotlin, mockk, junit)

## [0.6.0] (deprecated) - 2023-08-31

### Changed

- Update wiremock 2.27.2 -> 3.0.0!
- `withRequestQueryAndVariables` method has been changed to deprecate.

## [0.5.0] - 2023-08-11

### Added

- Added `GraphqlBodyMatcher.extensionName` which can used easily when using remote wiremock server.

### Changed

- Change parameter key `expectedQuery` to `expectedJson` for remote wiremock server.

## [0.4.0] - 2023-05-25

### Added

- Support Remote Wiremock Server.

## [0.3.0] - 2023-04-26

### Added

- Support Graphql Variables.

### Changed

- `withRequestQuery` method has been changed to `withRequestQueryAndVariables` and now takes `expectedVariables` as argument. `expectedVariables` is Nullable.
- Update junit 5.8.1 -> 5.9.2
- Update mockk-jvm 1.13.4 -> 1.13.5

## [0.2.1] - 2023-04-21

### Added

- Support fragment normalization.

## [0.2.0] - 2023-04-21

### Changed

- Use `withRequestJson or Query` instead of constructor.

## [0.1.x]

Prerelease Version.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

⚠️ **IMPORTANT**: Starting from version 0.6, this extension requires WireMock 3.x. WireMock 2.x is no longer supported from this version onwards.

*An extension for GraphQL testing with Wiremock*
_An extension for GraphQL testing with Wiremock_

GraphqlBodyMatcher is an extension for [WireMock](https://wiremock.org/) that allows for semantical verification of GraphQL requests.

GraphqlBodyMatcherは[WireMock](https://wiremock.org/)の拡張で、GraphQLのリクエストが意味的に一致しているかを検証します
GraphqlBodyMatcher は[WireMock](https://wiremock.org/)の拡張で、GraphQL のリクエストが意味的に一致しているかを検証します

## Overview 📖

Expand All @@ -15,13 +15,13 @@ GraphqlBodyMatcherは[WireMock](https://wiremock.org/)の拡張で、GraphQLの

For a comprehensive understanding of our matching logic and details on our match strategy, please refer to our [MatchStrategy documentation](./docs/MatchStrategy.md).

- この拡張機能は、空白の取り扱いに加えて、クエリをソートし正規化します。GraphQLのパースおよび正規化には`graphql-java`を使用しています。
- クエリだけでなく、変数も比較されます。変数のJSONの比較には`org.json.JSONObject.similar`を使用しますが、配列の順番も一致している必要があります。

詳しいマッチングロジックなど関しては、[MatchStrategyのドキュメント](./docs/MatchStrategy.md)を参照してください。
- この拡張機能は、空白の取り扱いに加えて、クエリをソートし正規化します。GraphQL のパースおよび正規化には`graphql-java`を使用しています。
- クエリだけでなく、変数も比較されます。変数の JSON の比較には`org.json.JSONObject.similar`を使用しますが、配列の順番も一致している必要があります。

詳しいマッチングロジックなど関しては、[MatchStrategy のドキュメント](./docs/MatchStrategy.md)を参照してください。

## Usage 🛠️

### For Gradle:

```groovy
Expand All @@ -30,7 +30,7 @@ repositories {
}
dependencies {
testImplementation 'io.github.nilwurtz:wiremock-graphql-extension:0.8.1'
testImplementation 'io.github.nilwurtz:wiremock-graphql-extension:0.8.2'
}
```

Expand All @@ -40,13 +40,13 @@ dependencies {
<dependency>
<groupId>io.github.nilwurtz</groupId>
<artifactId>wiremock-graphql-extension</artifactId>
<version>0.8.1</version>
<version>0.8.2</version>
<scope>test</scope>
</dependency>
```


## Code Examples 💡

Here are some code examples to get started.

```java Java
Expand Down Expand Up @@ -75,6 +75,7 @@ WireMock.stubFor(WireMock.post(WireMock.urlEqualTo("/graphql"))
}
}""")));
```

```kotlin Kotlin
import com.github.tomakehurst.wiremock.client.WireMock
import io.github.nilwurtz.GraphqlBodyMatcher
Expand Down Expand Up @@ -118,20 +119,23 @@ If you are using Wiremock on a remote server such as Docker, please see the conf
Please download `wiremock-graphql-extension-x.y.z-jar-with-dependencies.jar` from the Release section.

### Server Configuration

#### When running with `docker run`:

```
docker run -it --rm \
-p 8080:8080 \
--name wiremock \
-v /path/to/wiremock-graphql-extension-0.8.1-jar-with-dependencies.jar:/var/wiremock/extensions/wiremock-graphql-extension-0.8.1-jar-with-dependencies.jar \
-v /path/to/wiremock-graphql-extension-0.8.2-jar-with-dependencies.jar:/var/wiremock/extensions/wiremock-graphql-extension-0.8.2-jar-with-dependencies.jar \
wiremock/wiremock \
--extensions io.github.nilwurtz.GraphqlBodyMatcher
```

#### When building with `docker build`:

```dockerfile
FROM wiremock/wiremock:latest
COPY ./wiremock-graphql-extension-0.8.1-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.8.1-jar-with-dependencies.jar
COPY ./wiremock-graphql-extension-0.8.2-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.8.2-jar-with-dependencies.jar
```

### Client-side (Test) Configuration
Expand All @@ -151,6 +155,7 @@ public registerGraphQLWiremock(String query, String response) {
.willReturn(okJson(response)));
}
```

```kotlin Kotlin
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.client.WireMock.*
Expand All @@ -165,7 +170,9 @@ fun registerGraphQLWiremock(query: String, response: String) {
```

## License 📜

This project is licensed under the terms of the MIT License.

## Contributing 🤝
Contributions are welcome! Feel free to open an issue or submit a pull request if you have any improvements or suggestions.

Contributions are welcome! Feel free to open an issue or submit a pull request if you have any improvements or suggestions.
9 changes: 5 additions & 4 deletions e2e/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.nilwurtz</groupId>
Expand All @@ -22,7 +23,7 @@
<dependency>
<artifactId>wiremock-graphql-extension</artifactId>
<groupId>io.github.nilwurtz</groupId>
<version>0.8.1</version>
<version>0.8.2</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.gauge</groupId>
Expand Down Expand Up @@ -110,4 +111,4 @@
</plugins>
</build>

</project>
</project>
9 changes: 5 additions & 4 deletions examples/testcontainers-java/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>testcontainers-java-example</name>
Expand All @@ -15,7 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<wiremock.testcontainers.version>1.0-alpha-13</wiremock.testcontainers.version>
<testcontainers.version>1.19.0</testcontainers.version>
<extension.version>0.8.1</extension.version>
<extension.version>0.8.2</extension.version>
<wiremock.version>3.3.1</wiremock.version>
<junit.version>5.10.1</junit.version>
</properties>
Expand Down Expand Up @@ -98,7 +98,8 @@
<artifactId>wiremock-graphql-extension</artifactId>
<version>${extension.version}</version>
<classifier>jar-with-dependencies</classifier>
<destFileName>wiremock-graphql-extension-jar-with-dependencies.jar</destFileName>
<destFileName>
wiremock-graphql-extension-jar-with-dependencies.jar</destFileName>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
Expand Down
9 changes: 5 additions & 4 deletions examples/testcontainers-kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>testcontainers-kotlin</artifactId>
Expand All @@ -20,7 +20,7 @@
<wiremock.testcontainers.version>1.0-alpha-13</wiremock.testcontainers.version>
<testcontainers.version>1.19.0</testcontainers.version>
<kotlin.version>1.9.20</kotlin.version>
<extension.version>0.8.1</extension.version>
<extension.version>0.8.2</extension.version>
<wiremock.version>3.3.1</wiremock.version>
<junit.version>5.10.1</junit.version>
</properties>
Expand Down Expand Up @@ -83,7 +83,8 @@
<artifactId>wiremock-graphql-extension</artifactId>
<version>${extension.version}</version>
<classifier>jar-with-dependencies</classifier>
<destFileName>wiremock-graphql-extension-jar-with-dependencies.jar</destFileName>
<destFileName>
wiremock-graphql-extension-jar-with-dependencies.jar</destFileName>
<overWrite>true</overWrite>
</artifactItem>
</artifactItems>
Expand Down
8 changes: 4 additions & 4 deletions wiremock-graphql-extension/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>wiremock-graphql-extension</artifactId>
<groupId>io.github.nilwurtz</groupId>
<version>0.8.1</version>
<version>0.8.2</version>
<packaging>jar</packaging>
<name>wiremock-graphql-extension</name>
<description>A WireMock extension for handling GraphQL requests, allowing for easy mocking of GraphQL APIs in
Expand Down Expand Up @@ -292,4 +292,4 @@
<url>https://github.com/nilwurtz/wiremock-graphql-extension</url>
</scm>

</project>
</project>

0 comments on commit b581c26

Please sign in to comment.