@coderich/autograph 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/data/Pipeline.js +1 -0
- package/src/schema/Schema.js +4 -2
package/package.json
CHANGED
package/src/data/Pipeline.js
CHANGED
|
@@ -63,6 +63,7 @@ module.exports = class Pipeline {
|
|
|
63
63
|
Pipeline.define('$construct', params => Pipeline.resolve(params, 'construct'), { ignoreNull: false });
|
|
64
64
|
Pipeline.define('$restruct', params => Pipeline.resolve(params, 'restruct'), { ignoreNull: false });
|
|
65
65
|
Pipeline.define('$serialize', params => Pipeline.resolve(params, 'serialize'), { ignoreNull: false });
|
|
66
|
+
Pipeline.define('$deserialize', params => Pipeline.resolve(params, 'deserialize'), { ignoreNull: false });
|
|
66
67
|
Pipeline.define('$validate', params => Pipeline.resolve(params, 'validate'), { ignoreNull: false });
|
|
67
68
|
|
|
68
69
|
//
|
package/src/schema/Schema.js
CHANGED
|
@@ -16,7 +16,7 @@ const scalarKinds = [Kind.SCALAR_TYPE_DEFINITION, Kind.SCALAR_TYPE_EXTENSION];
|
|
|
16
16
|
const fieldKinds = [Kind.FIELD_DEFINITION];
|
|
17
17
|
const modelKinds = [Kind.OBJECT_TYPE_DEFINITION, Kind.OBJECT_TYPE_EXTENSION].concat(interfaceKinds);
|
|
18
18
|
const allowedKinds = modelKinds.concat(fieldKinds).concat(Kind.DOCUMENT, Kind.NON_NULL_TYPE, Kind.NAMED_TYPE, Kind.LIST_TYPE, Kind.DIRECTIVE).concat(scalarKinds).concat(enumKinds);
|
|
19
|
-
const pipelines = ['validate', 'construct', 'restruct', 'instruct', 'normalize', 'serialize'];
|
|
19
|
+
const pipelines = ['validate', 'construct', 'restruct', 'instruct', 'normalize', 'serialize', 'deserialize'];
|
|
20
20
|
const createPipelines = ['validate', 'construct', 'instruct', 'normalize', 'serialize'];
|
|
21
21
|
const updatePipelines = ['validate', 'restruct', 'instruct', 'normalize', 'serialize'];
|
|
22
22
|
// const validatePipelines = ['validate', 'instruct', 'normalize', 'serialize'];
|
|
@@ -481,6 +481,7 @@ module.exports = class Schema {
|
|
|
481
481
|
if (value === undefined) continue; // eslint-disable-line
|
|
482
482
|
if (docField.isArray) value = value == null ? value : Util.ensureArray(value);
|
|
483
483
|
if (docField.isEmbedded) value = Util.map(value, v => docField.model.docTransform(v));
|
|
484
|
+
if (docField.pipelines.deserialize.length) value = Pipeline.resolve({ model: $model, field: docField, value }, 'deserialize');
|
|
484
485
|
out[docField.name] = value;
|
|
485
486
|
}
|
|
486
487
|
return out;
|
|
@@ -707,6 +708,7 @@ module.exports = class Schema {
|
|
|
707
708
|
construct: [AutoGraphPipelineEnum!]
|
|
708
709
|
restruct: [AutoGraphPipelineEnum!]
|
|
709
710
|
serialize: [AutoGraphPipelineEnum!]
|
|
711
|
+
deserialize: [AutoGraphPipelineEnum!]
|
|
710
712
|
validate: [AutoGraphPipelineEnum!]
|
|
711
713
|
|
|
712
714
|
# TEMP TO APPEASE TRANSITION
|
|
@@ -927,7 +929,7 @@ module.exports = class Schema {
|
|
|
927
929
|
} : {}),
|
|
928
930
|
...readModels.reduce((prev, model) => {
|
|
929
931
|
return Object.assign(prev, {
|
|
930
|
-
[model]: Object.values(model.fields).filter(field => field.model?.isEntity).reduce((prev2, field) => {
|
|
932
|
+
[model]: Object.values(model.fields).filter(field => field.model?.isEntity && field.crud?.includes('r')).reduce((prev2, field) => {
|
|
931
933
|
return Object.assign(prev2, {
|
|
932
934
|
[field]: (doc, args, context, info) => {
|
|
933
935
|
if (!doc.$) doc = context[schema.namespace].resolver.toResultSet(model, doc); // Ensure resultSet
|