InteractiveQuery / FilterDSL

FieldResolver

Default field resolver implementation for js object graphs.


FilterDSL

The automaton filter DSL creates object graphs representations of filter expressions that can be evaluated as SQL, on Java objects and on JavaScript objects.

.not(operand)

Logical not condition.

Parameters

NameTypeDescription
operandConditionNode

Return Value

Type: ConditionNode

negated condition

.or(operands)

Logical or condition. Will remove null conditions

Parameters

NameTypeDescription
operands... ConditionNode

Return Value

Type: ConditionNode

ORed condition

.and(operands)

Logical or condition. Will ignore falsy operands.

Parameters

NameTypeDescription
operands... ConditionNode

Return Value

Type: ConditionNode

ORed condition

.condition(name, operands)

General Condition node. Useful for programmatically instantiating conditions. Not needed for fluent style conditions.

Parameters

NameTypeDescription
nameStringcondition name
operandsArray<ConditionNode>operands

Return Value

Type: ConditionNode

No description

.field(name)

Field / column reference.

Parameters

NameTypeDescription
nameStringfield name (e.g. "name", "owner.name")

Return Value

Type: Field

No description

.component(id, condition)

Component condition node. These nodes are just marker for which part of the condition originated from which component Logically they are evaluated as the condition they wrap.

Parameters

NameTypeDescription
idStringcomponent id
conditionConditionNodeactual condition for component

Return Value

Type: ConditionNode

No description

.value(value)

Creates a new value node

Parameters

NameTypeDescription
valueObjectscalar value of appropriate type

.values(type, values)

Creates a new values node that encapsulates a collection of scalar values (for e.g. the IN operator)

Parameters

NameTypeDescription
typeStringscalar type name
valuesObjectvar args of scalar value of appropriate type

Return Value

Type: Values

values node

.getConditionArgCount(name)

Returns the number of expected arguments for the condition with the given name.

Parameters

NameTypeDescription
nameStringcondition name

Return Value

Type: number

number of value arguments expected

.isLogicalCondition(node)

Returns true if the given condition node is either a logical and or a logical or condition.

Parameters

NameTypeDescription
nodeObjectnode

Return Value

Type: boolean

true if the node is either an "and" or an "or"

.findComponentNode(conditionNode, id)

Finds a component node with the given id.

Parameters

NameTypeDescription
conditionNodeObjectcondition structure root
idStringcomponent id

Return Value

Type: Object | null

component node or `null`

FilterDSL.Type

Enum object containting the node types

TypeDescription
FIELDfield / column reference
CONDITIONCondition node
VALUEValue node
VALUESValues node (for .in())
OPERATIONfield operation
COMPONENTcomponent marker

InteractiveQuery

Client-side implementation of the InteractiveQuery mechanism. Meant to be registered for all concrete types created for de.quinscape.automaton.model.data.InteractiveQuery

.rows()

Current result rows of the base type

.queryConfig()

Query config object used to create this query

.columnStates()

Array of column states for this query

.rowCount()

Total number of rows available for pagination

.setQueryConfig(config)

Set the new queryConfig without mobx printing warnings. This is supposed to be only called from the inside.

Parameters

NameTypeDescription
configObjectthe new query configuration

.update(queryConfig)

Updates the current iQuery base on a new query config. The given query config is merged with the current config so you only need to define the changes. Examples: ```js // page to second page iQuery.update({offset: 10}) // sorty by name descending iQuery.update({ sortFields: [ "!name" ] }) ```

Parameters

NameTypeDescription
queryConfigObjectquery config structure (see de.quinscape.automaton.model.data.QueryConfig)

Return Value

Type: Promise<* | never>

No description

.updateCondition(componentCondition)

Updates a component condition in the current query config state. If no component node is found, the current condition if present will be ANDed with the component condition

Parameters

NameTypeDescription
componentConditionObjectcondition node

.separate(result, varName)

Extracts a new independent iQuery object with a new Query containing only the selections for that iQuery.

Parameters

NameTypeDescription
resultObjectmulti iQuery result object
varNameStringvariable name of this query in the original query

compareConditions(a, b, compareValueNodes)

Does a deep-comparison between two conditions

Parameters

NameTypeDescription
aConditionNodecondition node A
bConditionNodecondition node B
compareValueNodesbooleancompare the value of value nodes (default = false)

Return Value

Type: boolean

true if the conditions are equal (ignoring values)


createMockedQuery(format, type, payload)

Creates a mocked query that returns a single constant result. If you need filtering or pagination on your mock, use createFilteredMockQuery

Parameters

NameTypeDescription
format------wire format
typeStringiQuery container type
payloadObject | functionconstant iQuery result to return from the mocked query or function producing a result from given variables

Return Value

Type: GraphQLQuery

mocked query object.


evaluateMemoryQuery(format, cachedDocument, queryConfig)

Filters a given cached iQuery document according to the give query config object.

Parameters

NameTypeDescription
format------WireFormat instance
cachedDocument------cached iQuery document containing all data
queryConfig------QueryConfig instance

filterTransformer(condition, resolverFactory)

Filter transformer function that transforms a condition as JSON object to an executable JS function.

Parameters

NameTypeDescription
conditionObjectJSON condition map
resolverFactoryFunctionfunction that creates a field resolver function for a given field name ( name => { return () => f(name) } )

getFirstValue(m)

Returns the first value from an object.

Parameters

NameTypeDescription
mobjectjs object

updateComponentCondition(compositeCondition, componentCondition)

Updates a logical condition composed of component conditions with a new condition for one of the components.

Parameters

NameTypeDescription
compositeConditionObjectlogical condition composed of component conditions.
componentConditionObjectnew component condition