Classes
GraphQLQuery
GraphQL query abstraction for both GraphQL queries and mutations. Can be used to parse application queries only once and then .execute() them. The graphql service will always create a new instance of GraphQLQuery on every request otherwise.
Example
// language=GraphQLconst myMutation = new GraphQLQuery(`mutation myMutation($fooo: String!){myMutation(foo: $foo)}`);
We most commonly use the declarative variant graphql to enable data injection.
Constructor
.getQueryDefinition()
Lazily parses the query string of this query and returns result.
Return Value
Type: QueryDefinitionNo description
.execute()
Executes this GraphQL query/mutation with the given variables
.clone()
Clone this query object.
Return Value
Type: GraphQLQuerynew graphql query
InteractiveQueryDefinition
Encapsulates a query and a default query config as user-editable query definition
MergeOperation
No description
OfflineQuery
Offline version of {@link InteractiveQuery} emulating sort, filter and paging functionality.
Constructor
.update(queryConfig)
Updates the current resolved rows based 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
Name | Type | Description |
---|---|---|
queryConfig | Object | query 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
Name | Type | Description |
---|---|---|
componentCondition | Object | condition node |
ViewState
Encapsulates the static view state in an automaton process. The process keeps the actual transition maps bound to process and scope for each of its states.
WorkingSet
Encapsulates a current set of changes to domain objects not yet persisted to the server-side.
.id()
Counter id for this WorkingSet
.onNextChange(cb)
Executes the given callback after the next update has been processed. This callback is only executed *once*.
Parameters
Name | Type | Description |
---|---|---|
cb | Function |
.registerBaseVersion(domainObject)
Registers the base version of an object before changing it within the working set. If an object with the same type and the same id is already registered, this method does nothing.
Parameters
Name | Type | Description |
---|---|---|
domainObject | object | domain object to register the base version of. Can be a complex GraphQL output graph. |
.addNew()
XXX: something similar to this needs to be done if we want to selective follow marked relations according to some
.addChanges(domainObject)
Adds a domain object as changed object. If it was formerly marked as new object, it will remain a new object, but with updated contents.
Parameters
Name | Type | Description |
---|---|---|
domainObject | object | domain object to register the base version of. Can be a complex GraphQL output graph. |
.markDeleted()
addRelationChanges(domainObject)
.revert(domainObject)
Reverts the changes for the given domain object in the working set.
Parameters
Name | Type | Description |
---|---|---|
domainObject | ------ |
.clear()
Forgets all changes.
.discard()
Discards all changes by reverting the observables registered as changed back to their original state
.lookup(type, id)
Looks up the registration for a given entity
Parameters
Name | Type | Description |
---|---|---|
type | ------ | entity type name |
id | ------ | entity id |
.isModified(entity)
Returns true, if there are actual modifications for the given entity, that is either one of its fields changed or a many-to-many connected entity changed
Parameters
Name | Type | Description |
---|---|---|
entity | Object | String | entity object or domain type |
.lookupBase(type, id)
Looks up the base object for an given entity
Parameters
Name | Type | Description |
---|---|---|
type | ------ | entity type name |
id | ------ | entity id |
.changes()
Returns the array of changed domain objects except for the deletions. These are the objects with actual changes. A changed object that has its changed changed back to the intial value is no longer changed.
.newObjects()
Returns an array of new objects of the given type. if no type is given, all new objects are returned.
.deletions()
Returns the registered deletions in this working set.
.merge()
Merges the current changes contained in the working set using the merge functionality and resets the working set.
.load(type, id, source)
Convenience method that loads the entity with the given name and type. If the entity is registered with the working set, that instance is returned. Otherwise the entity is loaded from the given source and registered. The source function has to make sure it is safe to edit the domain object directly and should clone the object if there is any doubt. load() does *not* clone.
Parameters
Name | Type | Description |
---|---|---|
type | String | Domain type name |
id | String | Entity id |
source | GraphQLQuery | function | GraphQL query to load the entity from or a function that returns a promise that resolves to the entity data ( (type,id) => Promise<Observable> ) |
Return Value
Type: Promise<object>Promise resolving to the referenced entity
.undo()
Changes all registered domain objects back to their original values. In contrast to clear() it keeps the registrations alive, so the objects will be immediately be open to accept other changes.
.reducer(iQuery, fn, initial)
A reactive reducer helper function. The given reducer function ( (domainObject,<T>) => <T> ) is applied to the combined set of domain objects from the given iQuery document and the working set.
Parameters
Name | Type | Description |
---|---|---|
iQuery | InteractiveQuery | iQuery document |
fn | function | reducer function |
initial | * | initial reducer value |
Return Value
Type: *reducer result
WorkingSetStatus
Enum for the status of an entity registration
.NEW()
Object is registered as a new object
.MODIFIED()
Object is pre-existing and modified.
.DELETED()
Object is marked as deleted.
.REGISTERED()
Base version for the object is registered, but no changes.