Class GraphqlStringCoercing
- java.lang.Object
-
- graphql.scalar.GraphqlStringCoercing
-
- All Implemented Interfaces:
Coercing<java.lang.String,java.lang.String>
public class GraphqlStringCoercing extends java.lang.Object implements Coercing<java.lang.String,java.lang.String>
The deprecated methods still have implementations in case code outside graphql-java is calling them but internally the call paths have been replaced.
-
-
Constructor Summary
Constructors Constructor Description GraphqlStringCoercing()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @Nullable java.lang.StringparseLiteral(@NonNull Value<?> input, @NonNull CoercedVariables variables, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale)Called during query execution to convert a query input AST node into a Java object acceptable for the scalar type.java.lang.StringparseLiteral(@NonNull java.lang.Object input)Deprecated.java.lang.StringparseValue(@NonNull java.lang.Object input)Deprecated.java.lang.StringparseValue(@NonNull java.lang.Object input, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale)Called to resolve an input from a query variable into a Java object acceptable for the scalar type.java.lang.Stringserialize(@NonNull java.lang.Object dataFetcherResult)Deprecated.@Nullable java.lang.Stringserialize(@NonNull java.lang.Object dataFetcherResult, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale)Called to convert a Java object result of a DataFetcher to a valid runtime value for the scalar type.@NonNull Value<?>valueToLiteral(@NonNull java.lang.Object input)Deprecated.@NonNull Value<?>valueToLiteral(@NonNull java.lang.Object input, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale)Converts an external input value to a literal (Ast Value).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface graphql.schema.Coercing
parseLiteral
-
-
-
-
Method Detail
-
serialize
@Deprecated public java.lang.String serialize(@NonNull java.lang.Object dataFetcherResult)
Deprecated.Description copied from interface:CoercingThis is deprecated and you should implementCoercing.serialize(Object, GraphQLContext, Locale)insteadCalled to convert a Java object result of a DataFetcher to a valid runtime value for the scalar type.
Note : Throw
CoercingSerializeExceptionif there is fundamental problem during serialization, don't return null to indicate failure.Note : You should not allow
RuntimeExceptions to come out of your serialize method, but rather catch them and fire them asCoercingSerializeExceptioninstead as per the method contract.
-
serialize
public @Nullable java.lang.String serialize(@NonNull java.lang.Object dataFetcherResult, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale) throws CoercingSerializeExceptionDescription copied from interface:CoercingCalled to convert a Java object result of a DataFetcher to a valid runtime value for the scalar type.Note : Throw
CoercingSerializeExceptionif there is fundamental problem during serialization, don't return null to indicate failure.Note : You should not allow
RuntimeExceptions to come out of your serialize method, but rather catch them and fire them asCoercingSerializeExceptioninstead as per the method contract.- Specified by:
serializein interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
dataFetcherResult- is never nullgraphQLContext- the graphql context in placelocale- the locale to use- Returns:
- a serialized value which may be null.
- Throws:
CoercingSerializeException- if value input can't be serialized
-
parseValue
@Deprecated public java.lang.String parseValue(@NonNull java.lang.Object input)
Deprecated.Description copied from interface:CoercingThis is deprecated and you should implementCoercing.parseValue(Object, GraphQLContext, Locale)insteadCalled to resolve an input from a query variable into a Java object acceptable for the scalar type.
Note : You should not allow
RuntimeExceptions to come out of your parseValue method, but rather catch them and fire them asCoercingParseValueExceptioninstead as per the method contract.Note : if input is explicit/raw value null, input coercion will return null before this method is called
- Specified by:
parseValuein interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- is never null- Returns:
- a parsed value which may be null
-
parseValue
public java.lang.String parseValue(@NonNull java.lang.Object input, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale) throws CoercingParseValueExceptionDescription copied from interface:CoercingCalled to resolve an input from a query variable into a Java object acceptable for the scalar type.Note : You should not allow
RuntimeExceptions to come out of your parseValue method, but rather catch them and fire them asCoercingParseValueExceptioninstead as per the method contract. Note : if input is explicit/raw value null, input coercion will return null before this method is called- Specified by:
parseValuein interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- is never nullgraphQLContext- the graphql context in placelocale- the locale to use- Returns:
- a parsed value which may be null
- Throws:
CoercingParseValueException- if value input can't be parsed
-
parseLiteral
@Deprecated public java.lang.String parseLiteral(@NonNull java.lang.Object input)
Deprecated.Description copied from interface:CoercingThis is deprecated and you should implementCoercing.parseLiteral(Value, CoercedVariables, GraphQLContext, Locale)insteadCalled during query validation to convert a query input AST node into a Java object acceptable for the scalar type. The input object will be an instance of
Value.Note : You should not allow
RuntimeExceptions to come out of your parseLiteral method, but rather catch them and fire them asCoercingParseLiteralExceptioninstead as per the method contract.Note : if input is literal
NullValue, input coercion will return null before this method is called- Specified by:
parseLiteralin interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- is never null- Returns:
- a parsed value which may be null
-
parseLiteral
public @Nullable java.lang.String parseLiteral(@NonNull Value<?> input, @NonNull CoercedVariables variables, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale) throws CoercingParseLiteralException
Description copied from interface:CoercingCalled during query execution to convert a query input AST node into a Java object acceptable for the scalar type. The input object will be an instance ofValue.Note : You should not allow
RuntimeExceptions to come out of your parseLiteral method, but rather catch them and fire them asCoercingParseLiteralExceptioninstead as per the method contract.Many scalar types don't need to implement this method because they don't take AST
VariableReferenceobjects and convert them into actual values. But for those scalar types that want to do this, then this method should be implemented. Note : if input is literalNullValue, input coercion will return null before this method is called- Specified by:
parseLiteralin interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- is never nullvariables- the resolved variables passed to the querygraphQLContext- the graphql context in placelocale- the locale to use- Returns:
- a parsed value which may be null
- Throws:
CoercingParseLiteralException- if input literal can't be parsed
-
valueToLiteral
@Deprecated public @NonNull Value<?> valueToLiteral(@NonNull java.lang.Object input)
Deprecated.Description copied from interface:CoercingThis is deprecated and you should implementCoercing.valueToLiteral(Object, GraphQLContext, Locale)insteadConverts an external input value to a literal (Ast Value).
IMPORTANT: the argument is validated before by calling
Coercing.parseValue(Object).- Specified by:
valueToLiteralin interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- an external input value- Returns:
- The literal matching the external input value.
-
valueToLiteral
public @NonNull Value<?> valueToLiteral(@NonNull java.lang.Object input, @NonNull GraphQLContext graphQLContext, @NonNull java.util.Locale locale)
Description copied from interface:CoercingConverts an external input value to a literal (Ast Value).IMPORTANT: the argument is validated before by calling
Coercing.parseValue(Object).- Specified by:
valueToLiteralin interfaceCoercing<java.lang.String,java.lang.String>- Parameters:
input- an external input valuegraphQLContext- the graphql context in placelocale- the locale to use- Returns:
- The literal matching the external input value.
-
-