graphql.schema.CoercingParseValueException Java Examples
The following examples show how to use
graphql.schema.CoercingParseValueException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scalars.java From besu with Apache License 2.0 | 5 votes |
@Override public String parseValue(final Object input) throws CoercingParseValueException { if (input instanceof UInt256Value) { return ((UInt256Value) input).toShortHexString(); } throw new CoercingParseValueException( "Unable to parse variable value " + input + " as an BigInt"); }
Example #2
Source File: Scalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
@Override public byte[] parseValue(Object input) { if (input instanceof String) { try { return Base64.getDecoder().decode((String) input); } catch (IllegalArgumentException e) { throw new CoercingParseValueException("Input string \"" + input + "\" is not a valid Base64 value", e); } } if (input instanceof byte[]) { return (byte[]) input; } throw valueParsingException(input, String.class, byte[].class); }
Example #3
Source File: Scalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
@Override public URL parseValue(Object input) { if (input instanceof String) { try { return new URL((String) input); } catch (MalformedURLException e) { throw new CoercingParseValueException("Input string \"" + input + "\" could not be parsed into a URL", e); } } if (input instanceof URL) { return (URL) input; } throw valueParsingException(input, String.class, URL.class); }
Example #4
Source File: JacksonScalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
@Override public ShortNode parseValue(Object input) { if (input instanceof Number || input instanceof String) { try { return ShortNode.valueOf(new BigInteger(input.toString()).shortValueExact()); } catch (ArithmeticException e) { throw new CoercingParseValueException(input + " does not fit into a short without a loss of precision"); } } if (input instanceof ShortNode) { return (ShortNode) input; } throw valueParsingException(input, Number.class, String.class, ShortNode.class); }
Example #5
Source File: JacksonScalars.java From graphql-spqr with Apache License 2.0 | 5 votes |
@Override public IntNode parseValue(Object input) { if (input instanceof Number || input instanceof String) { try { return IntNode.valueOf(new BigInteger(input.toString()).intValueExact()); } catch (ArithmeticException e) { throw new CoercingParseValueException(input + " does not fit into an int without a loss of precision"); } } if (input instanceof IntNode) { return (IntNode) input; } throw valueParsingException(input, Number.class, String.class, IntNode.class); }
Example #6
Source File: ProtoScalars.java From rejoiner with Apache License 2.0 | 5 votes |
@Override public ByteString parseValue(Object input) throws CoercingParseValueException { if (input instanceof String) { ByteString result = ByteString.copyFromUtf8((String) input); if (result == null) { throw new CoercingParseValueException( "Invalid value '" + input + "' for Bytes"); } return result; } if (input instanceof ByteString) { return (ByteString) input; } throw new CoercingParseValueException("Invalid value '" + input + "' for Bytes"); }
Example #7
Source File: ObjectNodeCoercing.java From stream-registry with Apache License 2.0 | 5 votes |
@Override public Object parseValue(Object input) throws CoercingParseValueException { try { JsonNode jsonNode = mapper.readTree(input.toString()); if (!jsonNode.isObject()) { throw new CoercingParseValueException("Expected 'ObjectNode', got: " + jsonNode); } return jsonNode; } catch (IOException e) { log.error("Error parsing value: {}", input, e); throw new CoercingParseValueException(e); } }
Example #8
Source File: Scalars.java From besu with Apache License 2.0 | 5 votes |
@Override public String parseValue(final Object input) throws CoercingParseValueException { if (input instanceof Address) { return input.toString(); } throw new CoercingParseValueException( "Unable to parse variable value " + input + " as an Address"); }
Example #9
Source File: Scalars.java From besu with Apache License 2.0 | 5 votes |
@Override public String parseValue(final Object input) throws CoercingParseValueException { if (input instanceof Bytes) { return input.toString(); } throw new CoercingParseValueException( "Unable to parse variable value " + input + " as an Bytes"); }
Example #10
Source File: Scalars.java From besu with Apache License 2.0 | 5 votes |
@Override public String parseValue(final Object input) throws CoercingParseValueException { if (input instanceof Bytes32) { return input.toString(); } throw new CoercingParseValueException( "Unable to parse variable value " + input + " as an Bytes32"); }
Example #11
Source File: Scalars.java From besu with Apache License 2.0 | 5 votes |
@Override public Number parseValue(final Object input) throws CoercingParseValueException { if (input instanceof Number) { return (Number) input; } else if (input instanceof String) { final String value = ((String) input).toLowerCase(); if (value.startsWith("0x")) { return Bytes.fromHexStringLenient(value).toLong(); } else { return Long.parseLong(value); } } throw new CoercingParseValueException( "Unable to parse variable value " + input + " as an Long"); }
Example #12
Source File: AddressScalarTest.java From besu with Apache License 2.0 | 4 votes |
@Test public void pareValueErrorTest() { thrown.expect(CoercingParseValueException.class); scalar.getCoercing().parseValue(addrStr); }
Example #13
Source File: Scalars.java From notification with Apache License 2.0 | 4 votes |
public static CoercingParseValueException valueParsingException( Object input, Class<?>... allowedTypes) { return new CoercingParseValueException(errorMessage(input, allowedTypes)); }
Example #14
Source File: Directives.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public Object parseValue(Object input) { throw new CoercingParseValueException(ERROR); }
Example #15
Source File: Scalars.java From graphql-spqr with Apache License 2.0 | 4 votes |
public static CoercingParseValueException valueParsingException(Object input, Class... allowedTypes) { return new CoercingParseValueException(errorMessage(input, allowedTypes)); }
Example #16
Source File: Scalars.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public Object parseValue(Object input) { throw new CoercingParseValueException("Class can not be used as input"); }
Example #17
Source File: BytesScalarTest.java From besu with Apache License 2.0 | 4 votes |
@Test public void pareValueErrorTest() { thrown.expect(CoercingParseValueException.class); scalar.getCoercing().parseValue(str); }
Example #18
Source File: ObjectNodeCoercingTest.java From stream-registry with Apache License 2.0 | 4 votes |
@Test(expected = CoercingParseValueException.class) public void parseValueNotValidJson() { underTest.parseValue("{"); }
Example #19
Source File: ObjectNodeCoercingTest.java From stream-registry with Apache License 2.0 | 4 votes |
@Test(expected = CoercingParseValueException.class) public void parseValueNotAnObjectNode() { underTest.parseValue("[]"); }
Example #20
Source File: LongScalarTest.java From besu with Apache License 2.0 | 4 votes |
@Test public void pareValueErrorTest() { thrown.expect(CoercingParseValueException.class); scalar.getCoercing().parseValue(invalidStrValue); }
Example #21
Source File: SmallRyeGraphQLServerMessages.java From smallrye-graphql with Apache License 2.0 | 4 votes |
@Message(id = 13, value = "Expected type [%s] but was [%s].") CoercingParseValueException coercingParseValueException(String expectedType, String actualType, @Cause Exception cause);
Example #22
Source File: _Any.java From federation-jvm with MIT License | 4 votes |
@Override public Object parseValue(Object input) throws CoercingParseValueException { return input; }
Example #23
Source File: BigIntScalarTest.java From besu with Apache License 2.0 | 4 votes |
@Test public void pareValueErrorTest() { thrown.expect(CoercingParseValueException.class); scalar.getCoercing().parseValue(str); }
Example #24
Source File: Bytes32ScalarTest.java From besu with Apache License 2.0 | 4 votes |
@Test public void pareValueErrorTest() { thrown.expect(CoercingParseValueException.class); scalar.getCoercing().parseValue(str); }