io.stargate.sgv2.graphql.schema.graphqlfirst.processor.QueryModel Maven / Gradle / Ivy
/*
* Copyright The Stargate Authors
*
* 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 io.stargate.sgv2.graphql.schema.graphqlfirst.processor;
import graphql.language.FieldDefinition;
import graphql.schema.DataFetcher;
import io.stargate.bridge.proto.QueryOuterClass.Consistency;
import io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe;
import io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.QueryFetcher;
import java.util.List;
import java.util.Optional;
public class QueryModel extends OperationModel {
// TODO implement more flexible rules
// This is a basic implementation that only allows a single-entity SELECT by full primary key.
// There will probably be significant changes when we support more scenarios: partial primary key
// (returning multiple entities), index lookups, etc
private final EntityModel entity;
private final List whereConditions;
private final Optional pagingStateArgumentName;
private final Optional limit;
private final Optional pageSize;
private final Optional consistencyLevel;
private final ReturnType returnType;
private final CqlKeyspaceDescribe keyspace;
QueryModel(
String parentTypeName,
FieldDefinition field,
EntityModel entity,
List whereConditions,
Optional pagingStateArgumentName,
Optional limit,
Optional pageSize,
Optional consistencyLevel,
ReturnType returnType,
CqlKeyspaceDescribe keyspace) {
super(parentTypeName, field);
this.entity = entity;
this.whereConditions = whereConditions;
this.pagingStateArgumentName = pagingStateArgumentName;
this.limit = limit;
this.pageSize = pageSize;
this.consistencyLevel = consistencyLevel;
this.returnType = returnType;
this.keyspace = keyspace;
}
public EntityModel getEntity() {
return entity;
}
public List getWhereConditions() {
return whereConditions;
}
/**
* If the query has an argument that was annotated with {@code @cql_pageState}, the name of that
* argument.
*/
public Optional getPagingStateArgumentName() {
return pagingStateArgumentName;
}
public Optional getLimit() {
return limit;
}
public Optional getPageSize() {
return pageSize;
}
public Optional getConsistencyLevel() {
return consistencyLevel;
}
public ReturnType getReturnType() {
return returnType;
}
@Override
public DataFetcher> getDataFetcher(MappingModel mappingModel) {
return new QueryFetcher(this, mappingModel, keyspace);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy