@coderich/autograph 0.13.42 → 0.13.43
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 +8 -3
package/package.json
CHANGED
package/src/data/Pipeline.js
CHANGED
|
@@ -62,6 +62,7 @@ module.exports = class Pipeline {
|
|
|
62
62
|
Pipeline.define('$construct', params => Pipeline.resolve(params, 'construct'), { ignoreNull: false });
|
|
63
63
|
Pipeline.define('$restruct', params => Pipeline.resolve(params, 'restruct'), { ignoreNull: false });
|
|
64
64
|
Pipeline.define('$serialize', params => Pipeline.resolve(params, 'serialize'), { ignoreNull: false });
|
|
65
|
+
Pipeline.define('$deserialize', params => Pipeline.resolve(params, 'deserialize'), { ignoreNull: false });
|
|
65
66
|
Pipeline.define('$validate', params => Pipeline.resolve(params, 'validate'), { ignoreNull: false });
|
|
66
67
|
|
|
67
68
|
//
|
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 inputPipelines = ['validate', 'construct', 'instruct', 'normalize', 'serialize'];
|
|
21
21
|
const scalars = ['ID', 'String', 'Float', 'Int', 'Boolean'];
|
|
22
22
|
|
|
@@ -418,7 +418,12 @@ module.exports = class Schema {
|
|
|
418
418
|
|
|
419
419
|
$model.transformers.doc.config({
|
|
420
420
|
shape: Object.values($model.fields).reduce((prev, curr) => {
|
|
421
|
-
const
|
|
421
|
+
const args = { model: $model, field: curr };
|
|
422
|
+
|
|
423
|
+
const rules = [
|
|
424
|
+
curr.name, // Rename key
|
|
425
|
+
a => Pipeline.$deserialize({ ...a, ...args, path: a.path.concat(curr.name) }),
|
|
426
|
+
];
|
|
422
427
|
if (curr.isArray) rules.unshift(({ value }) => (value == null ? value : Util.ensureArray(value)));
|
|
423
428
|
if (curr.isEmbedded) rules.unshift(({ value }) => Util.map(value, v => curr.model.transformers.doc.transform(v)));
|
|
424
429
|
return Object.assign(prev, { [curr.key]: rules });
|
|
@@ -623,6 +628,7 @@ module.exports = class Schema {
|
|
|
623
628
|
construct: [AutoGraphPipelineEnum!]
|
|
624
629
|
restruct: [AutoGraphPipelineEnum!]
|
|
625
630
|
serialize: [AutoGraphPipelineEnum!]
|
|
631
|
+
deserialize: [AutoGraphPipelineEnum!]
|
|
626
632
|
validate: [AutoGraphPipelineEnum!]
|
|
627
633
|
|
|
628
634
|
# TEMP TO APPEASE TRANSITION
|
|
@@ -630,7 +636,6 @@ module.exports = class Schema {
|
|
|
630
636
|
gqlScope: AutoGraphMixed # Dictate how GraphQL API behaves
|
|
631
637
|
dalScope: AutoGraphMixed # Dictate how the DAL behaves
|
|
632
638
|
transform: [AutoGraphPipelineEnum!]
|
|
633
|
-
deserialize: [AutoGraphPipelineEnum!]
|
|
634
639
|
) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR
|
|
635
640
|
|
|
636
641
|
directive @${link}(
|