Package codes.grow.packages.skywalking
Record Class GraphQLResponse
java.lang.Object
java.lang.Record
codes.grow.packages.skywalking.GraphQLResponse
- Record Components:
data- thedataobject, or empty when absent or nullerrors- the GraphQL errors, empty on success
public record GraphQLResponse(Optional<com.fasterxml.jackson.databind.JsonNode> data, List<GraphQLErrorInfo> errors)
extends Record
Result of a raw GraphQL call (
SkyWalkingClient.graphql(java.lang.String, java.util.Map<java.lang.String, ?>)): partial data is possible
next to errors.-
Constructor Summary
ConstructorsConstructorDescriptionGraphQLResponse(Optional<com.fasterxml.jackson.databind.JsonNode> data, List<GraphQLErrorInfo> errors) Normalises nulls. -
Method Summary
Modifier and TypeMethodDescriptionOptional<com.fasterxml.jackson.databind.JsonNode> data()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.errors()Returns the value of theerrorsrecord component.Optional<com.fasterxml.jackson.databind.JsonNode> Returns one field ofdata.static GraphQLResponsefromBody(com.fasterxml.jackson.databind.JsonNode body) Decodes a response body.booleanWhether the server reported errors.final inthashCode()Returns a hash code value for this object.voidthrowIfErrors(String operation) Throws the SDK error forerrors()(nothing when there are none).static SkyWalkingExceptiontoException(String operation, List<GraphQLErrorInfo> errors, UnaryOperator<String> redact) Maps GraphQL errors to an SDK error: anUnsupportedOperationExceptionon the server →UnsupportedException, anything else →ValidationException(bad input caught by the resolver).final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GraphQLResponse
public GraphQLResponse(Optional<com.fasterxml.jackson.databind.JsonNode> data, List<GraphQLErrorInfo> errors) Normalises nulls.- Parameters:
data- dataerrors- errors
-
-
Method Details
-
fromBody
Decodes a response body.- Parameters:
body- the JSON body- Returns:
- the response
-
hasErrors
public boolean hasErrors()Whether the server reported errors.- Returns:
- true when
errors()is not empty
-
field
Returns one field ofdata.- Parameters:
name- field name- Returns:
- the field, or empty when absent or null
-
throwIfErrors
Throws the SDK error forerrors()(nothing when there are none).- Parameters:
operation- operation name for the message- Throws:
SkyWalkingException- seetoException(java.lang.String, java.util.List<codes.grow.packages.skywalking.GraphQLErrorInfo>, java.util.function.UnaryOperator<java.lang.String>)
-
toException
public static SkyWalkingException toException(String operation, List<GraphQLErrorInfo> errors, UnaryOperator<String> redact) Maps GraphQL errors to an SDK error: anUnsupportedOperationExceptionon the server →UnsupportedException, anything else →ValidationException(bad input caught by the resolver). The message is redacted and truncated to 300 characters.- Parameters:
operation- operation nameerrors- the errors (not empty)redact- redaction of known secrets- Returns:
- the exception
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
data
Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-
errors
Returns the value of theerrorsrecord component.- Returns:
- the value of the
errorsrecord component
-