woonsan opened a new pull request #627:
URL: https://github.com/apache/jmeter/pull/627
## Description
New GraphQL HTTP Request sampler, just a GUI variation of the HTTP Request
sampler, was added.
Changes:
- Added `GraphQLHTTPSamplerGui` (extending `HTTPSamplerGui`) and
`GraphQLUrlConfigGui` (extending `UrlConfigGui`) in order to customize some UI
elements (e.g, hiding irrelevant UI elements in GraphQL requests, adding more
convenient GraphQL request content UI elements, etc.), with minimal and
backward-compatible refactoring in the base classes to make the customizations
possible.
- Added com.google.code.gson:gson library for JSON parsing and serialization.
- Site documentation updates.
## Motivation and Context
I have used HTTP Request sampler for GraphQL testing with setting request
body with escaped json strings like this:
```
{"operationName":null,"variables":{},"query":"{\n fineSomethings(text:
\"\", offset: 0, limit: 200) {\n offset\n limit\n count\n total\n
items {\n ... }\n }\n }\n }\n}\n"}
```
It is very hard to read and edit the GraphQL parameter content, especially
comparing with GraphQL client tools such as graphiql playground where you can
view or edit `Query` and `Variables` directly without any escaping.
It would be nice if we have a GraphQL HTTP Request sampler configuration for
better UX.
ASF Bugzilla ticket: https://bz.apache.org/bugzilla/show_bug.cgi?id=64752
## How Has This Been Tested?
In order to test it, we need a GraphQL server. We can test the feature with
this open source demo GraphQL server:
- https://github.com/apollographql/starwars-server
### Test Steps
- Clone the https://github.com/apollographql/starwars-server and
install/start it like the following:
```
git clone https://github.com/apollographql/starwars-server
cd starwars-server
npm install
npm start
```
The demo server will be available at http://localhost:8080/graphql.
(If you want, you can also visit http://localhost:8080/graphql in your
browser to see the `graphiql` tool.)
- Run JMeter and open
[xdocs/demos/SimpleGraphQLTestPlan.jmx](xdocs/demos/SimpleGraphQLTestPlan.jmx)
and start the test.
- Verify if the response is okay in the 'View Results Tree' listener.
### Potential affecting area
HTTP Request and AJP Request samplers are affected.
## Screenshots (if appropriate):
-
[xdocs/images/screenshots/graphql-http-request.png](xdocs/images/screenshots/graphql-http-request.png)

-
[xdocs/images/screenshots/graphql-http-request-vars.png](xdocs/images/screenshots/graphql-http-request-vars.png)

## Types of changes
- New feature (non-breaking change which adds functionality)
## Checklist:
- [x] My code follows the [code style][style-guide] of this project.
- [x] I have updated the documentation accordingly.
[style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]