Skip to content

Commit

Permalink
♻️ Use OperationalContext.Schema for resolving subschemas
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Mar 23, 2024
1 parent be34724 commit 5d126aa
Show file tree
Hide file tree
Showing 6 changed files with 491 additions and 91 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Print a warning when a stage takes over 10 seconds to finish
* Add `OperationalContext` class for keeping track of complex operations
* Use new `OperationalContext`-based classes for handling `Datasource` operations, getting rid of callbacks
* Use `OperationalContext.Schema` for resolving subschemas

## 1.4.0-alpha.3 (2024-02-25)

Expand Down
109 changes: 109 additions & 0 deletions lib/app/helper_datasource/schema_operational_context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* The Schema OperationalContext class
*
* @constructor
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*/
const SchemaContext = Function.inherits('Alchemy.OperationalContext.DatasourceOperationalContext', 'Schema');

/**
* Set the path to the schema we want
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {Object} string
*/
SchemaContext.setContextProperty('sub_schema_path');

/**
* Current association info
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {Object} association
*/
SchemaContext.setContextProperty('association');

/**
* The path to a value, a property name
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} value_property_name
*/
SchemaContext.setContextProperty('value_property_name');

/**
* The current local value
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} value_property_name
*/
SchemaContext.setContextProperty('local_value');

/**
* The remote model name (for remote schema resolution)
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} remote_model_name
*/
SchemaContext.setContextProperty('remote_model_name');

/**
* The remote foreign key (for remote schema resolution)
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {string} remote_foreign_key
*/
SchemaContext.setContextProperty('remote_foreign_key');

/**
* The external field (for remote schema resolution)
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {Alchemy.Field.Schema} external_field
*/
SchemaContext.setContextProperty('external_field');

/**
* "Our field name", from the perspective of `resolveRemoteSchemaRequest`
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {Alchemy.Field.Schema} our_field_name
*/
SchemaContext.setContextProperty('our_field_name');

/**
* "Our field value", from the perspective of `resolveRemoteSchemaRequest`
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 1.4.0
* @version 1.4.0
*
* @param {*} our_field_value
*/
SchemaContext.setContextProperty('our_field_value');
Loading

0 comments on commit 5d126aa

Please sign in to comment.