From 5905f02bd6f29f742e25f6b54bada629c7765abc Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 4 Nov 2022 11:01:58 +0000 Subject: [PATCH] Deprecate ResponseField getError and hasValue See gh-499 --- .../graphql/GraphQlResponse.java | 4 +- .../graphql/ResponseField.java | 59 +++++++++++++++---- .../graphql/client/ClientResponseField.java | 12 ++-- .../client/DefaultClientResponseField.java | 6 +- .../graphql/client/DefaultGraphQlClient.java | 2 +- .../graphql/client/FieldAccessException.java | 7 +-- .../graphql/client/GraphQlClient.java | 41 +++++-------- .../support/AbstractGraphQlResponse.java | 4 +- .../graphql/client/GraphQlClientTests.java | 23 ++++---- 9 files changed, 94 insertions(+), 64 deletions(-) diff --git a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java index fc809930..661b8556 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java @@ -78,8 +78,8 @@ public interface GraphQlResponse { * * @param path relative to the "data" key * @return representation for the field with further options to inspect or - * decode its value; use {@link ResponseField#hasValue()} to check if - * the field actually exists and has a value. + * decode its value; use {@link ResponseField#getValue()} to check if + * the field actually has a value. */ ResponseField field(String path); diff --git a/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java b/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java index c7ec8dce..5f0b3e6f 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java @@ -37,9 +37,13 @@ public interface ResponseField { *
  • {@code "true"} means the field is not {@code null}, and therefore valid, * although it may be partial with nested field {@link #getErrors() errors}. *
  • {@code "false"} means the field is {@code null} or doesn't exist; use - * {@link #getError()} to check if the field is {@code null} due to an error. + * {@link #getErrors()} to check for field errors, and + * {@link GraphQlResponse#isValid()} to check if the entire response is + * valid or not. * + * @deprecated as of 1.0.3 in favor of checking via {@link #getValue()} */ + @Deprecated boolean hasValue(); /** @@ -65,10 +69,10 @@ public interface ResponseField { /** * Return the error that provides the reason for a failed field. - *

    When the field does not {@link #hasValue() have} a - * value, this method looks for the first field error. According to the - * GraphQL spec, section 6.4.4, "Handling Field Errors", there should be - * only one error per field. The returned field error may be: + *

    When the field is {@code null}, this method looks for the first field + * error. According to the GraphQL spec, section 6.4.4, "Handling Field + * Errors", there should be only one error per field. The returned field + * error may be: *