public abstract class MutationFetcher<MutationModelT extends MutationModel,ResultT> extends CassandraFetcher<ResultT>
| Modifier and Type | Field and Description |
|---|---|
protected io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe |
keyspace |
protected MappingModel |
mappingModel |
protected MutationModelT |
model |
DEFAULT_CONSISTENCY, DEFAULT_PAGE_SIZE, DEFAULT_PARAMETERS, DEFAULT_SERIAL_CONSISTENCY| Modifier | Constructor and Description |
|---|---|
protected |
MutationFetcher(MutationModelT 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() |
protected List<io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.TypedKeyValue> |
computePrimaryKey(EntityModel entity,
List<BuiltCondition> whereConditions)
Given the where conditions generated for the current GraphQL query, try to identify the primary
key targeted by the generated CQL query.
|
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 CompletionStage<ResultT> |
get(graphql.schema.DataFetchingEnvironment environment,
StargateGraphqlContext context) |
protected graphql.language.SourceLocation |
getCurrentFieldLocation(graphql.schema.DataFetchingEnvironment environment) |
protected Function<List<io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.MutationResult>,graphql.execution.DataFetcherResult<Object>> |
getDeleteOrUpdateResultBuilder(graphql.schema.DataFetchingEnvironment environment) |
protected abstract io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.MutationPayload<ResultT> |
getPayload(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 graphql.ExceptionWhileDataFetching |
toGraphqlError(MutationResult.Failure failure,
graphql.language.SourceLocation location,
graphql.schema.DataFetchingEnvironment environment) |
protected graphql.ExceptionWhileDataFetching |
toGraphqlError(Throwable error,
graphql.language.SourceLocation location,
graphql.schema.DataFetchingEnvironment environment) |
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 MutationModelT extends MutationModel model
protected final MappingModel mappingModel
protected final io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace
protected MutationFetcher(MutationModelT model, MappingModel mappingModel, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
protected abstract io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.MutationPayload<ResultT> getPayload(graphql.schema.DataFetchingEnvironment environment, StargateGraphqlContext context)
protected CompletionStage<ResultT> get(graphql.schema.DataFetchingEnvironment environment, StargateGraphqlContext context)
get in class CassandraFetcher<CompletionStage<ResultT>>protected io.stargate.bridge.proto.QueryOuterClass.QueryParameters buildParameters()
protected graphql.ExceptionWhileDataFetching toGraphqlError(MutationResult.Failure failure, graphql.language.SourceLocation location, graphql.schema.DataFetchingEnvironment environment)
protected graphql.ExceptionWhileDataFetching toGraphqlError(Throwable error, graphql.language.SourceLocation location, graphql.schema.DataFetchingEnvironment environment)
protected graphql.language.SourceLocation getCurrentFieldLocation(graphql.schema.DataFetchingEnvironment environment)
protected Function<List<io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.MutationResult>,graphql.execution.DataFetcherResult<Object>> getDeleteOrUpdateResultBuilder(graphql.schema.DataFetchingEnvironment environment)
protected List<io.stargate.sgv2.graphql.schema.graphqlfirst.fetchers.deployed.TypedKeyValue> computePrimaryKey(EntityModel entity, List<BuiltCondition> whereConditions)
If the query targets multiple rows, we'll get a partial PK, but it doesn't matter because we
won't end up using it (see explanations in MutationPayload.getPrimaryKeys()).
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.