Commit Graph

105 Commits

Author SHA1 Message Date
Brian Clozel
2a54ef486d Apply checkstyle changes to spring-graphql-test
See gh-943
2024-04-04 22:06:11 +02:00
rstoyanchev
fb1f0ee0e7 Deserialize HTTP request body to POJO
Closes gh-905
2024-02-08 20:54:55 +00:00
rstoyanchev
78f7df2736 Consistently check errors in GraphQlTester
Closes gh-891
2024-01-30 09:24:26 +00:00
rstoyanchev
d717e80cb9 Minor refactoring in DefaultGraphQlTester 2023-05-07 21:31:53 +01:00
rstoyanchev
21f4520a37 Support nested paths in GraphQlTester
Closes gh-457
2023-05-07 21:19:03 +01:00
rstoyanchev
7fc4df74a6 Add request attributes to WebGraphQlRequest
Closes gh-633
2023-03-14 08:17:02 +00:00
rstoyanchev
66b3c82280 Add cookies to WebGraphQlRequest
Closes gh-626
2023-03-10 16:04:40 +00:00
rstoyanchev
dc90558d9a Configure ExecutionInput in ExecutionGraphQlServiceTester
Closes gh-615
2023-02-16 18:20:45 +00:00
Brian Clozel
d1300f56bf Add reachability metadata for GraphQL client resources
This commit adds reachability metadata for resources loaded by the
`GraphQlClient` and `GraphQlTester` when using the `document("name")`
API variant. This method loads the query file from the classpath at
particular locations, namely `"classpath:graphql-documents/"` and
`"classpath:graphql-test/"` with the `".graphql"` and `".gql"` file
extensions.

This commit adds the relevant resource metadata so that such resources
are loaded in the GraalVM native image at build time when the client or
the tester are reachable through the static analysis.

Fixes gh-575
2022-12-09 15:15:37 +01:00
rstoyanchev
2dafd5dfc7 Merge branch '1.0.x' 2022-11-04 08:40:30 +00:00
Johan Wigert
6004937ad2 Fix typo in Javadoc of GraphQlTester
Closes gh-523
2022-11-04 07:24:34 +00:00
rstoyanchev
ea8fed8800 Merge branch '1.0.x' 2022-10-17 17:44:19 +01:00
rstoyanchev
560c2b53f2 Polishing contribution
Closes gh-507
2022-10-17 16:58:56 +01:00
Koen Punt
da21f7438c Print actual elements in GraphQlTester
See gh-507
2022-10-17 16:32:42 +01:00
rstoyanchev
f680892dfc Switch to io.micrometer:context-propagation library
See gh-459
2022-08-31 21:29:11 +01:00
Brian Clozel
e522beaf5f Upgrade baseline to Java 17 and Jakarata EE 9
Closes gh-426
2022-06-24 15:07:42 +02:00
Brian Clozel
29dcded549 Polish
See gh-371
2022-05-17 09:01:58 +02:00
rstoyanchev
ed8c27923f Fix cyclic dependencies and polishing 2022-05-16 11:58:36 +01:00
Brian Clozel
c2c6ae6547 Expose map of "extensions" in GraphQlRequest
This commit adds support for protocol, vendor specific protocol
extensions in the GraphQL client requests.

Closes gh-371
2022-05-16 11:32:32 +02:00
rstoyanchev
b07e4fdd64 Avoid using JSONPath#getPath()
It does not return the original path and omits expressions.

Closes gh-377
2022-05-13 02:24:04 +01:00
rstoyanchev
8549060d19 Add start and stop for RSocket client and tester
Closes gh-378
2022-05-06 11:17:53 +01:00
Brian Clozel
85ad5bbfb4 Rever to "application/json" as default MIME type
As of #108, the `"application/graphql+json"` media type is supported and
has been made the default.

It seems that it is not ready for adoption now; so while we'll keep
supporting it, this commit reverts back to `"application/json"` as the
default media type for servers and clients.

Closes gh-375
2022-05-04 11:14:10 +02:00
rstoyanchev
218b16e022 JSON config in ExecutionGraphQlServiceTester builder
See gh-345
2022-04-12 15:15:07 +01:00
Brian Clozel
e455ebb3d8 Support application/graphql+json content type
The GraphQL HTTP spec now requires the `"application/graphql+json"`
content type.
This commit applies this type by default in the server and client
implementations. `"application/json"` is still accepted and produced if
requested by clients.

Closes gh-108
2022-04-04 13:34:18 +02:00
rstoyanchev
696f2cd02f Refine documentSource locations
Closes gh-338
2022-04-01 21:39:42 +01:00
rstoyanchev
9289f0a1b5 Add MockExecutionGraphQlService in testFixtures 2022-04-01 06:23:39 +01:00
rstoyanchev
b3f13b978a Refactoring in Client and Tester builder implementations
The default transport-specific client and tester extensions contained
their builder implementations, but it makes more sense the other way
around since the extensions are mainly about the builders they provide.
2022-03-29 14:47:35 +01:00
rstoyanchev
d41ced23c4 Add RSocketGraphQlTester
See gh-339
2022-03-29 11:49:54 +01:00
rstoyanchev
eb9a369f00 Rename ~.web package to ~.server
Now that RSocket is included, it's more obvious it's not just web.

See gh-339
2022-03-28 09:07:47 +01:00
rstoyanchev
6584b88301 Shorten names of [Web|RSocket]GraphQlHandlerInterceptor
See gh-339
2022-03-28 09:07:11 +01:00
rstoyanchev
83001522f6 Refactoring in DefaultGraphQlTester
Align with similar changes in GraphQlClient.
2022-03-21 15:04:53 +00:00
rstoyanchev
4d50ecd6f1 Revise JSON path options in GraphQlTester
Closes gh-278
2022-03-21 11:34:04 +00:00
rstoyanchev
3d638918f4 Polishing
Closes gh-327
2022-03-21 10:05:28 +00:00
Koen Punt
4e63970175 Fix implementation of containsExactly
See gh-327
2022-03-21 10:05:28 +00:00
rstoyanchev
dfff40085c Rename [Web|Socket]Interceptor
Use more qualified names [Web|Socket]GraphQlHandlerInterceptor to
differentiate with ClientGraphQlInterceptor and to align with other
types in the same package.
2022-03-21 09:04:52 +00:00
rstoyanchev
92547de5d0 Add client side interception
Closes gh-332
2022-03-21 04:25:54 +00:00
rstoyanchev
bb4ebf6cb8 Correct names of AbstractDirectTransport and subclasses
See gh-332
2022-03-21 04:24:26 +00:00
rstoyanchev
91e7f285fa Shorten GraphQlResponse[Field|Error] and rename GraphQlService
Rename GraphQlService to ExecutionGraphQlService following the renaming
of the request and response to ExecutionGraphQl[Request|Response].

See gh-332
2022-03-21 04:23:59 +00:00
rstoyanchev
67711f7331 Rename Web[Input|Output] to WebGraphQl[Request|Response]
See gh-332
2022-03-21 04:23:34 +00:00
rstoyanchev
182e9e66f0 Extract ExecutionGraphQl[Request|Response] interfaces
Rename the implementation classes Request[Input|Output] accordingly to
match the interfaces, and move them into the support package.

Create AbstractGraphQlResponse in the support package that
pre-implements response field access.

This leaves mainly contracts in the top-level package.

See gh-332
2022-03-21 04:22:01 +00:00
rstoyanchev
be05b031d6 Extract GraphQlRequest interface
See gh-332
2022-03-21 04:21:33 +00:00
rstoyanchev
db24c8f62b Replace GraphQLError with GraphQlResponseError
This allows exposing additional conveniences for inspecting errors.

See gh-10
2022-03-18 18:19:08 +00:00
rstoyanchev
96135183f5 Refactor MapGraphQlResponse
MapGraphQlResponse is a simple wrapper around the response map exposing
it as GraphQlResponse. It is now package private and made accessible
through a static factory method on GraphQlTransport.

See gh-10
2022-03-17 19:56:31 +00:00
rstoyanchev
38a9eb1b3c Align client with GraphQL Java error paths
DefaultClientGraphQlResponse now parses the path to a field and creates
the same parsed representation as GraphQL Java does and uses for
GraphQLError paths. This makes it easier to correlate fields to field
errors and eliminates the need for a dependency on JSONPath in the
client.

See gh-10
2022-03-15 09:00:28 +00:00
rstoyanchev
dcb752dde4 Introduce ClientGraphQlResponse
Extends GraphQlResponse with a subtype that exposes further options to
handle data and errors in the response from a client perspective.

See gh-10
2022-03-15 09:00:28 +00:00
rstoyanchev
15238072bb Introduce GraphQlResponse
Replace the use of ExecutionResult on the client side where we are
dealing with a response map rather, and also incorporate it into the
server-side hierarchy where it wraps an ExecutionResult instead.

See gh-10
2022-03-15 09:00:28 +00:00
rstoyanchev
f6b9fdfe7c Fix issue with matchesJson when JSONPath is a String
GraphQlTransport returns ExecutionResult with parsed JSON so for the
most part having MappingProvider is enough. However, when a JSONPath
evaluates to String (vs Map or List), the JsonSmartJsonProvider used by
default, throws UnsupportedOperationException from toJson.
2022-03-09 12:47:26 +00:00
rstoyanchev
71881f5e47 Expose convenience String url methods
See gh-317
2022-03-09 08:49:56 +00:00
Brian Clozel
c6d10d3ab8 Check for missing errors in GraphQlTester#executeAndVerify
Prior to this commit, the `GraphQlTester#executeAndVerify` method would
check that an `"$.errors"` JSON path exists within the response and
contains no value.

This should fail with valid GraphQL responses, as the spec says that a
response with no error should not contain the errors map at all:
http://spec.graphql.org/draft/#sec-Errors

This commit changes the assertion and instead checks for the absence of
the errors map in the response.

Fixes gh-318
2022-03-07 22:42:36 +01:00
rstoyanchev
1559c5989e Adapt CodecConfigurer to JSONPath MappingProvider
The JSON Encoder and Decoder implementations configured via
CodecConfigurer for HTTP and WebSocket are adapted to a JSONPath
MappingProvider and now automatically registered in JSONPath
configuration.

See gh-10, see gh-317
2022-03-07 10:39:59 +00:00