@Override protected void handleScalarError(Value value, GraphQLScalarType type) { errorMessage = "is not a valid '%s'"; arguments.add(type.getName()); argumentValue = value; }
/** * This allows you to add in new custom Scalar implementations beyond the standard set. * * @param scalarType the new scalar implementation * * @return the runtime wiring builder */ public Builder scalar(GraphQLScalarType scalarType) { scalars.put(scalarType.getName(), scalarType); return this; }
private static boolean inList(List<GraphQLScalarType> scalarList, String scalarTypeName) { return scalarList.stream().anyMatch(sc -> sc.getName().equals(scalarTypeName)); }
/** * Returns true if the scalar type is a standard one provided by graphql-java * * @param scalarType the type in question * * @return true if the scalar type is a graphql-java provided scalar */ public static boolean isStandardScalar(GraphQLScalarType scalarType) { return inList(STANDARD_SCALARS, scalarType.getName()); }
/** * Returns true if the scalar type is a scalar that is specified by the graphql specification * * @param scalarType the type in question * * @return true if the scalar type is is specified by the graphql specification */ public static boolean isGraphqlSpecifiedScalar(GraphQLScalarType scalarType) { return inList(GRAPHQL_SPECIFICATION_SCALARS, scalarType.getName()); }
private boolean isArgumentValueScalarLiteral(GraphQLScalarType scalarType, Value instanceValue) { try { scalarType.getCoercing().parseLiteral(instanceValue); return true; } catch (CoercingParseLiteralException ex) { log.debug("Attempted parsing literal into '{}' but got the following error: ", scalarType.getName(), ex); return false; } } }
@Override public TraversalControl visitGraphQLScalarType(GraphQLScalarType node, TraverserContext<GraphQLType> context) { assertTypeUniqueness(node, result); save(node.getName(), node); return super.visitGraphQLScalarType(node, context); }
public Builder(GraphQLScalarType existing) { name = existing.getName(); description = existing.getDescription(); coercing = existing.getCoercing(); definition = existing.getDefinition(); directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private TypePrinter<GraphQLScalarType> scalarPrinter() { return (out, type, visibility) -> { if (!options.isIncludeScalars()) { return; } boolean printScalar; if (ScalarInfo.isStandardScalar(type)) { printScalar = false; //noinspection RedundantIfStatement if (options.isIncludeExtendedScalars() && !ScalarInfo.isGraphqlSpecifiedScalar(type)) { printScalar = true; } } else { printScalar = true; } if (printScalar) { printComments(out, type, ""); out.format("scalar %s%s\n\n", type.getName(), directivesString(type.getDirectives())); } }; }
@Override public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) { return Scalars.GraphQLString.getName(); }
@Override public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) { return Scalars.GraphQLFloat.getName(); }
@Override public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) { return Scalars.GraphQLBigDecimal.getName(); }
@Override public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) { return Scalars.GraphQLChar.getName(); }
/** * This allows you to add in new custom Scalar implementations beyond the standard set. * * @param scalarType the new scalar implementation * * @return the runtime wiring builder */ public Builder scalar(GraphQLScalarType scalarType) { scalars.put(scalarType.getName(), scalarType); return this; }
/** * Returns true if the scalar type is a standard one provided by graphql-java * * @param scalarType the type in question * * @return true if the scalar type is a graphql-java provided scalar */ public static boolean isStandardScalar(GraphQLScalarType scalarType) { return inList(STANDARD_SCALARS, scalarType.getName()); }
/** * Returns true if the scalar type is a scalar that is specified by the graphql specification * * @param scalarType the type in question * * @return true if the scalar type is is specified by the graphql specification */ public static boolean isGraphqlSpecifiedScalar(GraphQLScalarType scalarType) { return inList(GRAPHQL_SPECIFICATION_SCALARS, scalarType.getName()); }
private boolean isArgumentValueScalarLiteral(GraphQLScalarType scalarType, Value instanceValue) { try { scalarType.getCoercing().parseLiteral(instanceValue); return true; } catch (CoercingParseLiteralException ex) { log.debug("Attempted parsing literal into '{}' but got the following error: ", scalarType.getName(), ex); return false; } } }
@Override protected String getTypeName(AnnotatedType type, BuildContext buildContext) { return Scalars.toGraphQLScalarType(type.getType()).getName(); }
@Override public TraversalControl visitGraphQLScalarType(GraphQLScalarType node, TraverserContext<GraphQLType> context) { assertTypeUniqueness(node, result); save(node.getName(), node); return super.visitGraphQLScalarType(node, context); }
public Builder(GraphQLScalarType existing) { name = existing.getName(); description = existing.getDescription(); coercing = existing.getCoercing(); definition = existing.getDefinition(); directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }