/** * A factory method for creating list types so that when used with static imports allows * more readable code such as * {@code .type(list(GraphQLString)) } * * @param wrappedType the type to wrap as being a list * * @return a GraphQLList of that wrapped type */ public static GraphQLList list(GraphQLType wrappedType) { return new GraphQLList(wrappedType); }
.field(GraphQLFieldDefinition.newFieldDefinition() .name("stoptimes") .type(new GraphQLList(stoptimeType)) .dataFetcher(environment -> ((StopTimesInPattern) environment.getSource()).times) .build()) .field(GraphQLFieldDefinition.newFieldDefinition() .name("stops") .type(new GraphQLList(new GraphQLNonNull(stopType))) .dataFetcher(environment -> ((StopCluster) environment.getSource()).children) .build()) .field(GraphQLFieldDefinition.newFieldDefinition() .name("routes") .type(new GraphQLList(new GraphQLNonNull(routeType))) .dataFetcher(environment -> index.patternsForStop .get((Stop) environment.getSource()) .field(GraphQLFieldDefinition.newFieldDefinition() .name("patterns") .type(new GraphQLList(patternType)) .dataFetcher(environment -> index.patternsForStop .get((Stop) environment.getSource())) .field(GraphQLFieldDefinition.newFieldDefinition() .name("transfers") //TODO: add max distance as parameter? .type(new GraphQLList(stopAtDistanceType)) .dataFetcher(environment -> index.stopVertexForStop .get(environment.getSource())
/** * A factory method for creating list types so that when used with static imports allows * more readable code such as * {@code .type(list(GraphQLString)) } * * @param wrappedType the type to wrap as being a list * * @return a GraphQLList of that wrapped type */ public static GraphQLList list(GraphQLType wrappedType) { return new GraphQLList(wrappedType); }
@Override public GraphQLType wrapType(GraphQLType interiorType, TypeSpecContainer originalObject) { if (!canWrapList(originalObject)) { return interiorType; } return new GraphQLList(interiorType); }
@Override public GraphQLInputType getInputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { Class<?> classType = (Class<?>) type; return new GraphQLList(graphQLObjectMapper.getInputType(classType.getComponentType())); }
@Override public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { Class<?> classType = (Class<?>) type; return new GraphQLList(graphQLObjectMapper.getOutputType(classType.getComponentType())); }
@Override public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; return new GraphQLList(graphQLObjectMapper.getOutputType(parameterizedType.getActualTypeArguments()[0])); } else { return new GraphQLList(graphQLObjectMapper.getOutputType(Object.class)); } }
@Override public GraphQLInputType getInputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; return new GraphQLList(graphQLObjectMapper.getInputType(parameterizedType.getActualTypeArguments()[0])); } else { return new GraphQLList(graphQLObjectMapper.getInputType(Object.class)); } }
/** * Returns a non-null list of non-null types */ public static GraphQLOutputType stdList(GraphQLType type) { return new GraphQLNonNull( new GraphQLList( new GraphQLNonNull( type ) ) ); }
@Override public GraphQLOutputType toGraphQLType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) { return new GraphQLList(operationMapper.toGraphQLType(getElementType(javaType), buildContext)); }
@Override public GraphQLInputType toGraphQLInputType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) { return new GraphQLList(operationMapper.toGraphQLInputType(getElementType(javaType), buildContext)); }
@Override public GraphQLOutputType getOutputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { Class<?> classType = (Class<?>) type; Class<?> enumClassType = classType.getComponentType(); GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum() .name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, enumClassType)); for (Object value : enumClassType.getEnumConstants()) { enumType.value(value.toString(), value); } return new GraphQLList(enumType.build()); }
@Override public GraphQLInputType getInputType(IGraphQLObjectMapper graphQLObjectMapper, Type type) { Class<?> classType = (Class<?>) type; Class<?> enumClassType = classType.getComponentType(); GraphQLEnumType.Builder enumType = GraphQLEnumType.newEnum() .name(graphQLObjectMapper.getTypeNamingStrategy().getTypeName(graphQLObjectMapper, enumClassType)); for (Object value : enumClassType.getEnumConstants()) { enumType.value(value.toString(), value); } return new GraphQLList(enumType.build()); }
public static GraphQLArgument multiStringArg (String name) { return newArgument() .name(name) .type(new GraphQLList(GraphQLString)) .build(); }
@Override public GraphQLOutputType toGraphQLType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) { return new GraphQLList(new GraphQLNonNull( mapEntry( operationMapper.toGraphQLType(getElementType(javaType, 0), buildContext), operationMapper.toGraphQLType(getElementType(javaType, 1), buildContext), buildContext))); }
@Override public GraphQLInputType toGraphQLInputType(AnnotatedType javaType, OperationMapper operationMapper, Set<Class<? extends TypeMapper>> mappersToSkip, BuildContext buildContext) { return new GraphQLList(new GraphQLNonNull( mapEntry( operationMapper.toGraphQLInputType(getElementType(javaType, 0), buildContext), operationMapper.toGraphQLInputType(getElementType(javaType, 1), buildContext), buildContext))); }
private GraphQLList buildEdgesObject(String relationName, GraphQLOutputType entityType) { return new GraphQLList(newObject() .name("__edges__" + relationName) .field(newFieldDefinition() .name("node") .dataFetcher(dataFetcher) .type(entityType)) .build()); }
private GraphQLList buildEdgesObject(String relationName, GraphQLOutputType entityType) { return new GraphQLList(newObject() .name("__edges__" + relationName) .field(newFieldDefinition() .name("node") .dataFetcher(dataFetcher) .type(entityType)) .build()); }
public static GraphQLFieldDefinition field (String tableName) { return newFieldDefinition() .name(tableName) .type(new GraphQLList(GraphQLGtfsSchema.routeType)) .argument(stringArg("namespace")) .argument(multiStringArg("route_id")) .dataFetcher(new JDBCFetcher(tableName, null)) .build(); }
@Override public GraphQLObjectType edgeType(String name, GraphQLOutputType nodeType, GraphQLInterfaceType nodeInterface, List<GraphQLFieldDefinition> edgeFields) { return newObject() .name(name + "Chunk") .field(newFieldDefinition() .name("totalCount") .description("The total number of the elements") .type(GraphQLInt)) .field(newFieldDefinition() .name("data") .description("The data itself") .type(new GraphQLList(nodeType))) .build(); }