com.yahoo.elide.graphql.GraphQLScalars Maven / Gradle / Ivy
/*
* Copyright 2017, Yahoo Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root for terms.
*/
package com.yahoo.elide.graphql;
import com.yahoo.elide.core.utils.coerce.CoerceUtil;
import com.yahoo.elide.core.utils.coerce.converters.Serde;
import graphql.language.IntValue;
import graphql.language.StringValue;
import graphql.schema.Coercing;
import graphql.schema.CoercingParseValueException;
import graphql.schema.GraphQLScalarType;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
/**
* Additional scalar/serializers for built-in graphql types.
*/
@Slf4j
public class GraphQLScalars {
private static final String ERROR_BAD_EPOCH_TYPE = "Date must be provided as string or integral in epoch millis";
// TODO: Should we make this a class that can be configured? Should determine if there are other customizeable
// TODO: scalar types.
// NOTE: Non-final so it's overrideable if someone wants _different_ date representations.
public static GraphQLScalarType GRAPHQL_DATE_TYPE = new GraphQLScalarType(
"Date",
"Built-in date",
new Coercing() {
@Override
public Object serialize(Object o) {
Serde
© 2015 - 2025 Weber Informatics LLC | Privacy Policy