public class QueryFetcher extends CassandraFetcher<ResultT>
| Modifier and Type | Field and Description |
|---|---|
protected io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe |
keyspace |
protected MappingModel |
mappingModel |
DEFAULT_CONSISTENCY, DEFAULT_PAGE_SIZE, DEFAULT_PARAMETERS, DEFAULT_SERIAL_CONSISTENCY| Constructor and Description |
|---|
QueryFetcher(QueryModel model,
MappingModel mappingModel,
io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace) |
| Modifier and Type | Method and Description |
|---|---|
protected List<BuiltCondition> |
bindIf(List<ConditionModel> conditions,
Predicate<String> hasArgument,
Function<String,Object> getArgument,
io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace) |
protected List<BuiltCondition> |
bindWhere(List<ConditionModel> conditions,
Predicate<String> hasArgument,
Function<String,Object> getArgument,
Function<List<ConditionModel>,Optional<String>> validator,
io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
Given the WHERE conditions that were inferred from an operation signature, find out which
arguments are actually present in a runtime invocation, and bind the corresponding conditions.
|
protected io.stargate.bridge.proto.QueryOuterClass.QueryParameters |
buildParameters(graphql.schema.DataFetchingEnvironment environment) |
protected void |
copyRowToEntity(io.stargate.bridge.proto.QueryOuterClass.Row row,
List<io.stargate.bridge.proto.QueryOuterClass.ColumnSpec> columns,
Map<String,Object> entityData,
EntityModel entity)
Copies a CQL row to a map representing the given entity.
|
protected Object |
get(graphql.schema.DataFetchingEnvironment environment,
StargateGraphqlContext context) |
protected io.stargate.bridge.proto.QueryOuterClass.ResultSet |
query(EntityModel entity,
List<BuiltCondition> whereConditions,
Optional<Integer> limit,
io.stargate.bridge.proto.QueryOuterClass.QueryParameters parameters,
StargateGraphqlContext context)
Queries one or more instances of an entity for the given conditions.
|
protected io.stargate.bridge.proto.QueryOuterClass.Value |
toCqlValue(Object graphqlValue,
io.stargate.bridge.proto.QueryOuterClass.TypeSpec cqlType,
io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace) |
protected List<Map<String,Object>> |
toEntities(io.stargate.bridge.proto.QueryOuterClass.ResultSet resultSet,
EntityModel entity) |
protected Object |
toGraphqlValue(io.stargate.bridge.proto.QueryOuterClass.Value cqlValue,
io.stargate.bridge.proto.QueryOuterClass.TypeSpec cqlType,
graphql.language.Type<?> graphqlType) |
protected Map<String,Object> |
toSingleEntity(io.stargate.bridge.proto.QueryOuterClass.ResultSet resultSet,
EntityModel entity) |
get, isApplied, isAppliedprotected final MappingModel mappingModel
protected final io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace
public QueryFetcher(QueryModel model, MappingModel mappingModel, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
protected io.stargate.bridge.proto.QueryOuterClass.QueryParameters buildParameters(graphql.schema.DataFetchingEnvironment environment)
protected Object get(graphql.schema.DataFetchingEnvironment environment, StargateGraphqlContext context)
get in class CassandraFetcher<Object>protected io.stargate.bridge.proto.QueryOuterClass.Value toCqlValue(Object graphqlValue, io.stargate.bridge.proto.QueryOuterClass.TypeSpec cqlType, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
protected Object toGraphqlValue(io.stargate.bridge.proto.QueryOuterClass.Value cqlValue, io.stargate.bridge.proto.QueryOuterClass.TypeSpec cqlType, graphql.language.Type<?> graphqlType)
protected io.stargate.bridge.proto.QueryOuterClass.ResultSet query(EntityModel entity, List<BuiltCondition> whereConditions, Optional<Integer> limit, io.stargate.bridge.proto.QueryOuterClass.QueryParameters parameters, StargateGraphqlContext context)
protected Map<String,Object> toSingleEntity(io.stargate.bridge.proto.QueryOuterClass.ResultSet resultSet, EntityModel entity)
protected List<Map<String,Object>> toEntities(io.stargate.bridge.proto.QueryOuterClass.ResultSet resultSet, EntityModel entity)
protected void copyRowToEntity(io.stargate.bridge.proto.QueryOuterClass.Row row,
List<io.stargate.bridge.proto.QueryOuterClass.ColumnSpec> columns,
Map<String,Object> entityData,
EntityModel entity)
protected List<BuiltCondition> bindWhere(List<ConditionModel> conditions, Predicate<String> hasArgument, Function<String,Object> getArgument, Function<List<ConditionModel>,Optional<String>> validator, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
Example:
// Query definition
type Query { readings(sensorId: ID!, hour: Int, minute: Int): [SensorReading] }
// Inferred conditions:
sensorId = ? AND hour = ? AND minute = ?
// GraphQL call:
{ readings(sensorId: "xyz", hour: 12) { value } }
// Actual conditions:
sensorId = 'xyz' AND hour = 12
hasArgument - how to know if an argument is present (this is abstracted because in some
cases the values are not directly arguments, but instead inner fields of an object
argument).getArgument - how to get the value of an argument (same).validator - a validation function that will be applied to the actual conditions, to check
that they form a valid where clause.protected List<BuiltCondition> bindIf(List<ConditionModel> conditions, Predicate<String> hasArgument, Function<String,Object> getArgument, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
Copyright © 2022. All rights reserved.