GraphQLConversionUtils { public GraphQLScalarType classToScalarType(Class<?> clazz) { if (clazz.equals(int.class) || clazz.equals(Integer.class)) { return Scalars.GraphQLInt; } else if (clazz.equals(boolean.class) || clazz.equals(Boolean.class)) { return Scalars.GraphQLBoolean; } else if (clazz.equals(long.class) || clazz.equals(Long.class)) { return Scalars.GraphQLLong; } else if (clazz.equals(float.class) || clazz.equals(Float.class)) { return Scalars.GraphQLFloat; } else if (clazz.equals(double.class) || clazz.equals(Double.class)) { return Scalars.GraphQLFloat; } else if (clazz.equals(short.class) || clazz.equals(Short.class)) { return Scalars.GraphQLShort; } else if (clazz.equals(String.class)) { return Scalars.GraphQLString; } else if (clazz.equals(BigDecimal.class)) { return Scalars.GraphQLBigDecimal; } else if (Date.class.isAssignableFrom(clazz)) { return GraphQLScalars.GRAPHQL_DATE_TYPE; } else if (scalarMap.containsKey(clazz)) { return scalarMap.get(clazz); } return null; } GraphQLConversionUtils(EntityDictionary entityDictionary, NonEntityDictionary nonEntityDictionary); GraphQLScalarType classToScalarType(Class<?> clazz); GraphQLEnumType classToEnumType(Class<?> enumClazz); GraphQLList classToQueryMap(Class<?> keyClazz, Class<?> valueClazz, DataFetcher fetcher); GraphQLList classToInputMap(Class<?> keyClazz,
                                       Class<?> valueClazz); GraphQLOutputType attributeToQueryObject(Class<?> parentClass,
                                                    Class<?> attributeClass,
                                                    String attribute,
                                                    DataFetcher fetcher); GraphQLInputType attributeToInputObject(Class<?> parentClass,
                                                   Class<?> attributeClass,
                                                   String attribute); GraphQLObjectType classToQueryObject(
            Class<?> clazz,
            DataFetcher fetcher); GraphQLInputObjectType classToInputObject(Class<?> clazz);  }
@Test public void testGraphQLConversionUtilsClassToScalarType() { CoerceUtil.register(OffsetDateTime.class, new OffsetDateTimeSerde()); GraphQLConversionUtils graphQLConversionUtils = new GraphQLConversionUtils(new EntityDictionary(new HashMap<>()), new NonEntityDictionary()); GraphQLScalarType type = graphQLConversionUtils.classToScalarType(OffsetDateTime.class); assertNotNull(type); String expected = "OffsetDateTime"; assertEquals(expected, type.getName()); }