Commit Graph

546 Commits

Author SHA1 Message Date
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
08597c9e8a Recreate SimpleTypeConverter if ConversionService not set
Closes gh-315
2022-03-21 04:21:02 +00:00
rstoyanchev
982cbbaa45 Extract GraphQlResponseField in the top-level package
GraphQlResponseField is now extracted as a super type at the top-level
package and is exposed from GraphQlResponse. ClientGraphQlResponseField
extends this to provide decoding options.

The change ensures consistency with both GraphQlResponseField and
GraphQlResponseError accessible through GraphQlResponse, also making
both available for client and server side handling.

See gh-10
2022-03-18 18:19:15 +00:00
rstoyanchev
cdd8b67fed Refine GraphQlResponseField getError()
Instead of a simple check, looking for an associated field error at or
above the field, this method now more focused on finding the reason for
a failure when the field has no value.

This allows performing a more thorough search including cases when the
field error is at, above, or even below (e.g. non-null nested field
that bubbled up), in the end falling back on request errors (e.g.
failed response without any field errors).

Also, rename ResponseField to GraphQlResponseField and move to a
top-level class.

See gh-10
2022-03-18 18:19:15 +00:00
rstoyanchev
827b70b71d Update GraphQlResponseError contract
Add a String path representation making it easy to filter errors by
path using String comparison, and refine nullability.

Take advantage of the String error paths to simplify internal filtering
of error fields.

See gh-10
2022-03-18 18:19:15 +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
3c30376cba Refine null handling in GraphQlClient for retrieve
If a field is null but without errors, i.e. declared optional in the
schema, it is more natural for toEntity to complete empty instead of
raising a FieldAccessException.

This aligns better with the execute method where handling the field
directly allows treating a null but valid field as optional.

See gh-10
2022-03-17 17:27:40 +00:00
Brian Clozel
b2b1e2d506 Document custom className extractor config
This commit documents how to configure a custom className Extractor
strategy in the `ClassNameTypeResolver`. This also adds an example of a
`GraphQlSourceBuilderCustomizer` in Spring Boot.

Closes gh-334
2022-03-17 17:23:38 +01:00
rstoyanchev
9102bdbc77 Replace isValid with hasValue in ResponseField
hasValue is more meaningful because it means valid and with some value
that could be decoded, which in turn allows removing Nullable from
toEntity/List.

Or if there is no value, getError() can be used to differentiate
between a failed field vs a null field declared optional.

See gh-10
2022-03-17 13:37:16 +00:00
rstoyanchev
5e95fcf60a Refine getError(s) methods on ResponseField
getError now returns either the error at the field or on a parent
field, which provides a reliable answer for why a field failed even
for a field whose path is below where the error occurred.

getErrors likewise now also includes errors above. There is still no
need for special logic to get only errors below since where there is
a field value, errors are below anyway.

See gh-10
2022-03-17 13:37:16 +00:00
Mark Paluch
f28d3dc2a0 Initialize ProjectedPayloadMethodArgumentResolver with ApplicationContext
We now initialize the argument resolver with a context instead of
relying on …Aware callbacks that are not supported by
AnnotatedControllerConfigurer.

Closes gh-333
2022-03-17 12:17:21 +01:00
Mark Paluch
4653e94976 Remove raw-type cast in QuerydslDataFetcher
No longer required as Spring Data accepts MultiMap's containing object values.

Closes gh-311
2022-03-16 14:49:16 +01:00
Brian Clozel
22c1472bcc Fix CI pipeline configuration
See gh-331
2022-03-16 14:38:02 +01:00
Brian Clozel
0cf2ce023d Use Concourse Release Script as Docker image in CI
Instead of embeddeding the Concourse Release Scripts application as a
JAR in the CI image, this commit is now using the published Docker image
for this.
2022-03-16 14:26:53 +01:00
Brian Clozel
2b6dd8f1e1 Generate CHANGELOG during release promotion
Closes gh-331
2022-03-16 14:26:24 +01:00
Brian Clozel
d847211d0f Upgrade to Gradle 7.4.1 2022-03-16 14:26:00 +01:00
Brian Clozel
f197e2606d Add SDKMAN! file for JDK env selection
Closes gh-330
2022-03-16 14:25:21 +01:00
Brian Clozel
0346474357 Upgrade to ubuntu:focal-20220302 in CI image 2022-03-16 13:53:39 +01:00
Brian Clozel
4d3c349e34 Upgrade JDK versions in CI image 2022-03-16 13:52:56 +01:00
rstoyanchev
4d115c01cc Upgrade dependencies
GraphQL Java 18.0
Reactor 2020.0.17
Spring Framework, Spring Data, Spring Security snapshots
2022-03-16 10:00:37 +00:00
rstoyanchev
0967a6e7b7 Update documentation for GraphQlClient
See gh-10
2022-03-15 09:00:28 +00:00
rstoyanchev
e7b2f72d55 Add RetrieveSpec to GraphQlClient
Provides a shortcut alternative to the execute methods, for decoding
a single field from the response.

See gh-10
2022-03-15 09:00:28 +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
3214a9cfc9 Introduce GraphQlClientException hierarchy
Refine exception handling and ensure a hierarchy of exceptions that
allows differentiating between transport errors vs field errors while
accessing an invalid data or field.

See gh-10
2022-03-15 09:00:28 +00:00
rstoyanchev
eb3c8d1a7e Refine status code in WebSocket client transport
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
Brian Clozel
77e9835d3a Fix typo in reference documentation 2022-03-10 11:11:31 +01:00
Brian Clozel
83d26467e7 Document why Jackson annotations are not used
This commit explains why Jackson annotations have no impact on the
serialization/deserialization process. Instead applications should
describe and coerce types using scalars.

Fixes gh-321
2022-03-10 11:10:09 +01:00
rstoyanchev
1e652f800b Polishing 2022-03-10 09:48:37 +00:00
rstoyanchev
fb521e9b6f Add section on GraphQlClient to the reference docs
See gh-10
2022-03-10 09:48:14 +00:00
rstoyanchev
f568bce8a5 Correctly bind nested empty list
Closes gh-301
2022-03-09 21:24:31 +00:00
rstoyanchev
f42563424e Do not create "error" message from ExecutionResult
Fix gh-320
2022-03-09 12:47:26 +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
4818ee6c81 Upgrade samples to match the GraphQlTest updates
See gh-310
2022-03-09 12:47:26 +00:00
rstoyanchev
19793a6e74 Revert "Pin version to 1.0.0-M5 in samples"
This reverts commit b40375f1f2.
2022-03-09 08:57:10 +00:00
rstoyanchev
71881f5e47 Expose convenience String url methods
See gh-317
2022-03-09 08:49:56 +00:00
rstoyanchev
7459637808 Revise GraphQlTester documentation
Closes gh-317
2022-03-09 08:49:34 +00:00
rstoyanchev
caa717e358 Move repo.spring.io up in the order
I'm getting very slow times on failures to resolve Boot snapshots
through the gradlePluginPortal (3-4 min build time). Moving it down
after repo.spring.io restores regular build times.
2022-03-08 17:21:38 +00:00
rstoyanchev
c9640b6134 Respond to GraphQL over WebSocket "ping" type messages
Closes gh-270
2022-03-08 16:44:03 +00:00
rstoyanchev
878c643672 Refactor GraphQlMessage and add GraphQlMessageType enum
See gh-270
2022-03-08 12:50:32 +00:00
rstoyanchev
ec00547130 Add handleConnectionClosed to WebSocketInterceptor
Closes gh-276
2022-03-08 08:51:20 +00:00
rstoyanchev
35359b0b24 Add sessionId to WebSocketInterceptor callbacks
See gh-276
2022-03-08 08:51:10 +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
b40375f1f2 Pin version to 1.0.0-M5 in samples
This is necessary until Boot catches up with spring-graphql snapshots.
2022-03-07 10:39:59 +00:00