{"id":18875813,"url":"https://github.com/wiremock/wiremock-graphql-extension","last_synced_at":"2025-07-22T10:36:38.872Z","repository":{"id":153600753,"uuid":"624935468","full_name":"wiremock/wiremock-graphql-extension","owner":"wiremock","description":"GraphQL extension for WireMock","archived":false,"fork":false,"pushed_at":"2024-01-04T12:19:41.000Z","size":108,"stargazers_count":21,"open_issues_count":6,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-09T10:06:06.087Z","etag":null,"topics":["api","graphql","kotlin","wiremock","wiremock-extension"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiremock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-07T16:20:24.000Z","updated_at":"2024-04-24T08:23:17.000Z","dependencies_parsed_at":"2024-01-04T13:42:54.943Z","dependency_job_id":null,"html_url":"https://github.com/wiremock/wiremock-graphql-extension","commit_stats":null,"previous_names":["wiremock/wiremock-graphql-extension","nilwurtz/wiremock-graphql-extension"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-graphql-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-graphql-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-graphql-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-graphql-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiremock","download_url":"https://codeload.github.com/wiremock/wiremock-graphql-extension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223639348,"owners_count":17177816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","graphql","kotlin","wiremock","wiremock-extension"],"created_at":"2024-11-08T06:09:15.549Z","updated_at":"2025-07-22T10:36:38.862Z","avatar_url":"https://github.com/wiremock.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WireMock GraphQL Extension\n\n---\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cimg src=\"https://wiremock.org/images/wiremock-cloud/wiremock_cloud_logo.png\" alt=\"WireMock Cloud Logo\" height=\"20\" align=\"left\"\u003e\n\u003cstrong\u003eWireMock OSS is supported by WireMock Cloud. Please consider trying it out for rapid GraphQL mocking with advanced features like dynamic state and federation.\u003c/strong\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n---\n\n⚠️ **IMPORTANT**: Starting from version 0.6, this extension requires WireMock 3.x. WireMock 2.x is no longer supported from this version onwards.\n\n_An extension for GraphQL testing with Wiremock_\n\nGraphqlBodyMatcher is an extension for [WireMock](https://wiremock.org/) that allows for semantical verification of GraphQL requests.\n\nGraphqlBodyMatcher は[WireMock](https://wiremock.org/)の拡張で、GraphQL のリクエストが意味的に一致しているかを検証します。\n\n## Overview 📖\n\n- In addition to handling whitespaces, the extension sorts and normalizes queries. The GraphQL parsing and normalizing is handled by `graphql-java`.\n- Beyond just queries, it also compares variables. For the comparison of JSON variables, [EqualToJsonPattern](https://github.com/wiremock/wiremock/blob/3.3.1/src/main/java/com/github/tomakehurst/wiremock/matching/EqualToJsonPattern.java) is used. It's important to note that the order of arrays must match.\n\nFor a comprehensive understanding of our matching logic and details on our match strategy, please refer to our [MatchStrategy documentation](./docs/MatchStrategy.md).\n\n- この拡張機能は、空白の取り扱いに加えて、クエリをソートし正規化します。GraphQL のパースおよび正規化には`graphql-java`を使用しています。\n- クエリだけでなく、変数も比較されます。変数の JSON の比較には`org.json.JSONObject.similar`を使用しますが、配列の順番も一致している必要があります。\n\n詳しいマッチングロジックなど関しては、[MatchStrategy のドキュメント](./docs/MatchStrategy.md)を参照してください。\n\n## Usage 🛠️\n\n### For Gradle:\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    testImplementation 'io.github.nilwurtz:wiremock-graphql-extension:0.9.0'\n}\n```\n\n### For Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.nilwurtz\u003c/groupId\u003e\n    \u003cartifactId\u003ewiremock-graphql-extension\u003c/artifactId\u003e\n    \u003cversion\u003e0.9.0\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## Code Examples 💡\n\nHere are some code examples to get started.\n\n```java Java\nimport com.github.tomakehurst.wiremock.client.WireMock;\nimport io.github.nilwurtz.GraphqlBodyMatcher;\n\nimport java.util.Map;\n\nvar expectedQuery = \"\"\"\n        query HeroInfo($id: Int) {\n            hero(id: $id) {\n                name\n            }\n        }\n        \"\"\";\nvar expectedVariables = Map.of(\"id\", 1);\n\nWireMock.stubFor(WireMock.post(WireMock.urlEqualTo(\"/graphql\"))\n        .andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.parameters(expectedQuery, expectedVariables))\n        .willReturn(WireMock.okJson(\"\"\"\n                {\n                    \"data\": {\n                        \"hero\": {\n                            \"name\": \"example\"\n                        }\n                    }\n                }\"\"\")));\n```\n\n```kotlin Kotlin\nimport com.github.tomakehurst.wiremock.client.WireMock\nimport io.github.nilwurtz.GraphqlBodyMatcher\n\nval expectedQuery = \"\"\"\n    query HeroInfo(${'$'}id: Int) {\n        hero(id: ${'$'}id) {\n            name\n        }\n    }\n\"\"\".trimIndent()\nval expectedVariables = mapOf(\"id\" to 1)\n\nWireMock.stubFor(\n    WireMock.post(WireMock.urlEqualTo(\"/graphql\"))\n        .andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.parameters(expectedQuery, expectedVariables))\n        .willReturn(\n            WireMock.okJson(\"\"\"\n                {\n                    \"data\": {\n                        \"hero\": {\n                            \"name\": \"example\"\n                        }\n                    }\n                }\n            \"\"\".trimIndent()\n            )\n        )\n)\n```\n\nAs we head towards a 1.0 release, we are focusing on supporting both the WireMock standalone and the WireMock Java API\nwith the same paradigm. This is done through the use of `WireMock.requestMatching()` or `MappingBuilder#andMatching()`.\nTo that end, the `withRequestQueryAndVariables` method has been deprecated from version 0.6.0 onwards and\n`withRequestJson` and `withRequest` methods have been deprecated from version 0.9.0 onwards.\n\n## Running with a Remote Wiremock Server 🌍\n\nIf you are using Wiremock on a remote server such as Docker, please see the configurations below:\n\nPlease download `wiremock-graphql-extension-x.y.z-jar-with-dependencies.jar` from the Release section.\n\n### Server Configuration\n\n#### When running with `docker run`:\n\n```\ndocker run -it --rm \\\n      -p 8080:8080 \\\n      --name wiremock \\\n      -v /path/to/wiremock-graphql-extension-0.9.0-jar-with-dependencies.jar:/var/wiremock/extensions/wiremock-graphql-extension-0.9.0-jar-with-dependencies.jar \\\n      wiremock/wiremock \\\n      --extensions io.github.nilwurtz.GraphqlBodyMatcher\n```\n\n#### When building with `docker build`:\n\n```dockerfile\nFROM wiremock/wiremock:latest\nCOPY ./wiremock-graphql-extension-0.9.0-jar-with-dependencies.jar /var/wiremock/extensions/wiremock-graphql-extension-0.9.0-jar-with-dependencies.jar\n```\n\n### Client-side (Test) Configuration\n\nNOTE: When using a Remote Wiremock Server, you're requested to manage everything within a single JSON format.\n\n```java Java\nimport com.github.tomakehurst.wiremock.client.WireMock;\nimport io.github.nilwurtz.GraphqlBodyMatcher;\n\nimport static com.github.tomakehurst.wiremock.client.WireMock.*;\n\npublic registerGraphQLWiremock(String query, String response) {\n    WireMock(8080).register(\n        post(urlPathEqualTo(endPoint))\n            .andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.parameters(query))\n            .willReturn(okJson(response)));\n}\n```\n\n```kotlin Kotlin\nimport com.github.tomakehurst.wiremock.client.WireMock\nimport com.github.tomakehurst.wiremock.client.WireMock.*\nimport io.github.nilwurtz.GraphqlBodyMatcher\n\nfun registerGraphQLWiremock(query: String, response: String) {\n    WireMock(8080).register(\n        post(urlPathEqualTo(endPoint))\n            .andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.parameters(query))\n            .willReturn(okJson(response)))\n}\n```\n\n## License 📜\n\nThis project is licensed under the terms of the MIT License.\n\n## Contributing 🤝\n\nContributions are welcome! Feel free to open an issue or submit a pull request if you have any improvements or suggestions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiremock%2Fwiremock-graphql-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiremock%2Fwiremock-graphql-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiremock%2Fwiremock-graphql-extension/lists"}