Commit Graph

106 Commits

Author SHA1 Message Date
Brian Clozel
6de47bd2d3 Make test classes package private
See gh-1184
2025-04-08 15:27:26 +02:00
rstoyanchev
bd8a633eac AbstractGraphQlTesterBuilder copies extensions/attributes
Closes gh-1135
2025-03-11 18:14:26 +00:00
rstoyanchev
5682740dee GraphQlTester provides access to underlying response
Closes gh-1131
2025-03-11 18:14:26 +00:00
Stéphane Nicoll
fc55c53abc Avoid usage of JsonExpectationsHelper#assertEquals
This has been deprecated in Spring Framework 6.2.

Closes gh-1107
Signed-off-by: Stéphane Nicoll <stephane.nicoll@broadcom.com>
2025-01-13 10:22:28 +01:00
Brian Clozel
a9a8d0b745 Add fragments support in GraphQlTester
This commit adds support for GraphQL fragments with `GraphQlTester`.
Fragments allow to avoid repetition in GraphQL requests by reusing
field selection sets.

For example, the "releases" fragment can be reused in multiple queries
and make the overall document shorter:

```
query frameworkReleases {
  project(slug: "spring-framework") {
    name
    ...releases
  }
}
query graphqlReleases {
  project(slug: "spring-graphql") {
    name
    ...releases
  }
}

fragment releases on Project {
  releases {
    version
  }
}
```

With this change, `GraphQlTester` accepts fragments as `String` or can
load them by their name using the configured `DocumentSource`, similarly
to the document support.

Closes gh-964
2024-06-03 18:27:19 +02:00
rstoyanchev
4d2cde83e4 Polishing contribution
Closes gh-969
2024-05-21 08:38:40 +01:00
kutlueren
1318ca4316 Allow Map of variables in GraphQlTester
See gh-969
2024-05-21 07:03:15 +01:00
Brian Clozel
c9556035ca Configure interceptors on WebSocketGraphQlTester
This commit adds two new methods on the `WebSocketGraphQlTester` builder
to configure `GraphQlClientInterceptor` instances on the client.
For now, this is only accessible on the WebSocket tester but could be
promoted to a higher level builder in the future.

Closes gh-823
2024-04-19 15:34:07 +02:00
Brian Clozel
d27580f6b3 Add Remote Address to WebGraphQlRequest
This commit makes available the client remote address to various GraphQL
request implementations.

Closes gh-945
2024-04-15 15:37:05 +02:00
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
Johan Wigert
6004937ad2 Fix typo in Javadoc of GraphQlTester
Closes gh-523
2022-11-04 07:24:34 +00: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
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