Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2017 IntroPro Ventures Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.introproventures.graphql.jpa.query.schema.impl;
import static com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder.PAGE_PAGES_PARAM_NAME;
import static com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder.PAGE_TOTAL_PARAM_NAME;
import static com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder.QUERY_SELECT_PARAM_NAME;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.extractPageArgument;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.findArgument;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getAliasOrName;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getFields;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getPageArgument;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.getSelectionField;
import static com.introproventures.graphql.jpa.query.support.GraphQLSupport.searchByFieldName;
import com.introproventures.graphql.jpa.query.schema.JavaScalars;
import graphql.GraphQLException;
import graphql.language.Argument;
import graphql.language.EnumValue;
import graphql.language.Field;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLScalarType;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* JPA Query DataFetcher implementation that fetches entities with page and where criteria expressions
*
* @author Igor Dianov
*
*/
class GraphQLJpaQueryDataFetcher implements DataFetcher> {
private static final Logger logger = LoggerFactory.getLogger(GraphQLJpaQueryDataFetcher.class);
public static final String AGGREGATE_PARAM_NAME = "aggregate";
public static final String COUNT_FIELD_NAME = "count";
public static final String GROUP_FIELD_NAME = "group";
public static final String BY_FILED_NAME = "by";
public static final String FIELD_ARGUMENT_NAME = "field";
public static final String OF_ARGUMENT_NAME = "of";
private final int defaultMaxResults;
private final int defaultPageLimitSize;
private final boolean enableDefaultMaxResults;
private final GraphQLJpaQueryFactory queryFactory;
private GraphQLJpaQueryDataFetcher(Builder builder) {
this.queryFactory = builder.queryFactory;
this.defaultMaxResults = builder.defaultMaxResults;
this.defaultPageLimitSize = builder.defaultPageLimitSize;
this.enableDefaultMaxResults = builder.enableDefaultMaxResults;
}
@Override
public PagedResult