@envelop/core 2.3.2-alpha-c913692.0 → 2.3.2-alpha-fd02291.0
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/index.js +11 -13
- package/index.mjs +11 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1101,7 +1101,7 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1101
1101
|
if (isPromise(schema$)) {
|
|
1102
1102
|
schemaSet$ = schema$.then(schemaObj => {
|
|
1103
1103
|
setSchema(schemaObj);
|
|
1104
|
-
|
|
1104
|
+
return schemaObj;
|
|
1105
1105
|
});
|
|
1106
1106
|
}
|
|
1107
1107
|
else {
|
|
@@ -1109,20 +1109,21 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
},
|
|
1111
1111
|
onValidate({ validateFn, params, setValidationFn, extendContext }) {
|
|
1112
|
-
|
|
1112
|
+
// If schemaSet promise is still ongoing
|
|
1113
|
+
if (schemaSet$ != null) {
|
|
1113
1114
|
if (validateSchema) {
|
|
1114
1115
|
extendContext({
|
|
1115
|
-
[VALIDATE_FN]: (
|
|
1116
|
+
[VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
|
|
1116
1117
|
});
|
|
1117
1118
|
}
|
|
1118
1119
|
setValidationFn(() => []);
|
|
1119
1120
|
}
|
|
1120
1121
|
},
|
|
1121
1122
|
async onContextBuilding({ context, extendContext, breakContextBuilding }) {
|
|
1123
|
+
// If schemaSet promise is still ongoing
|
|
1122
1124
|
if (context[VALIDATE_FN]) {
|
|
1123
|
-
const schema = await schemaSet$;
|
|
1124
1125
|
const validateFn = context[VALIDATE_FN];
|
|
1125
|
-
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(
|
|
1126
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn();
|
|
1126
1127
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1127
1128
|
extendContext({
|
|
1128
1129
|
[VALIDATION_ERRORS]: errors,
|
|
@@ -1132,6 +1133,7 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1132
1133
|
}
|
|
1133
1134
|
},
|
|
1134
1135
|
onExecute({ args: { contextValue }, setResultAndStopExecution }) {
|
|
1136
|
+
// If validation errors are set in context
|
|
1135
1137
|
if (contextValue[VALIDATION_ERRORS]) {
|
|
1136
1138
|
setResultAndStopExecution({
|
|
1137
1139
|
errors: contextValue[VALIDATION_ERRORS],
|
|
@@ -1147,8 +1149,6 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1147
1149
|
if (isPromise(schema$)) {
|
|
1148
1150
|
schemaSet$ = schema$.then(schemaObj => {
|
|
1149
1151
|
setSchema(schemaObj);
|
|
1150
|
-
// Once the schema is completely resolved, we don't need to keep the logic below.
|
|
1151
|
-
schemaSet$ = undefined;
|
|
1152
1152
|
return schemaObj;
|
|
1153
1153
|
});
|
|
1154
1154
|
}
|
|
@@ -1157,11 +1157,10 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1157
1157
|
}
|
|
1158
1158
|
},
|
|
1159
1159
|
onValidate({ validateFn, params, setValidationFn, extendContext }) {
|
|
1160
|
-
|
|
1161
|
-
if (schemaSet$) {
|
|
1160
|
+
if (schemaSet$ != null) {
|
|
1162
1161
|
if (validateSchema) {
|
|
1163
1162
|
extendContext({
|
|
1164
|
-
[VALIDATE_FN]: (
|
|
1163
|
+
[VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
|
|
1165
1164
|
});
|
|
1166
1165
|
}
|
|
1167
1166
|
setValidationFn(() => []);
|
|
@@ -1169,10 +1168,9 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1169
1168
|
},
|
|
1170
1169
|
async onContextBuilding({ context, extendContext, breakContextBuilding }) {
|
|
1171
1170
|
// If schemaSet promise is still ongoing
|
|
1172
|
-
if (
|
|
1173
|
-
const schema = await schemaSet$;
|
|
1171
|
+
if (context[VALIDATE_FN]) {
|
|
1174
1172
|
const validateFn = context[VALIDATE_FN];
|
|
1175
|
-
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(
|
|
1173
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn();
|
|
1176
1174
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1177
1175
|
extendContext({
|
|
1178
1176
|
[VALIDATION_ERRORS]: errors,
|
package/index.mjs
CHANGED
|
@@ -1097,7 +1097,7 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1097
1097
|
if (isPromise(schema$)) {
|
|
1098
1098
|
schemaSet$ = schema$.then(schemaObj => {
|
|
1099
1099
|
setSchema(schemaObj);
|
|
1100
|
-
|
|
1100
|
+
return schemaObj;
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
1103
|
else {
|
|
@@ -1105,20 +1105,21 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
},
|
|
1107
1107
|
onValidate({ validateFn, params, setValidationFn, extendContext }) {
|
|
1108
|
-
|
|
1108
|
+
// If schemaSet promise is still ongoing
|
|
1109
|
+
if (schemaSet$ != null) {
|
|
1109
1110
|
if (validateSchema) {
|
|
1110
1111
|
extendContext({
|
|
1111
|
-
[VALIDATE_FN]: (
|
|
1112
|
+
[VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
|
|
1112
1113
|
});
|
|
1113
1114
|
}
|
|
1114
1115
|
setValidationFn(() => []);
|
|
1115
1116
|
}
|
|
1116
1117
|
},
|
|
1117
1118
|
async onContextBuilding({ context, extendContext, breakContextBuilding }) {
|
|
1119
|
+
// If schemaSet promise is still ongoing
|
|
1118
1120
|
if (context[VALIDATE_FN]) {
|
|
1119
|
-
const schema = await schemaSet$;
|
|
1120
1121
|
const validateFn = context[VALIDATE_FN];
|
|
1121
|
-
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(
|
|
1122
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn();
|
|
1122
1123
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1123
1124
|
extendContext({
|
|
1124
1125
|
[VALIDATION_ERRORS]: errors,
|
|
@@ -1128,6 +1129,7 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
|
1128
1129
|
}
|
|
1129
1130
|
},
|
|
1130
1131
|
onExecute({ args: { contextValue }, setResultAndStopExecution }) {
|
|
1132
|
+
// If validation errors are set in context
|
|
1131
1133
|
if (contextValue[VALIDATION_ERRORS]) {
|
|
1132
1134
|
setResultAndStopExecution({
|
|
1133
1135
|
errors: contextValue[VALIDATION_ERRORS],
|
|
@@ -1143,8 +1145,6 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1143
1145
|
if (isPromise(schema$)) {
|
|
1144
1146
|
schemaSet$ = schema$.then(schemaObj => {
|
|
1145
1147
|
setSchema(schemaObj);
|
|
1146
|
-
// Once the schema is completely resolved, we don't need to keep the logic below.
|
|
1147
|
-
schemaSet$ = undefined;
|
|
1148
1148
|
return schemaObj;
|
|
1149
1149
|
});
|
|
1150
1150
|
}
|
|
@@ -1153,11 +1153,10 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
},
|
|
1155
1155
|
onValidate({ validateFn, params, setValidationFn, extendContext }) {
|
|
1156
|
-
|
|
1157
|
-
if (schemaSet$) {
|
|
1156
|
+
if (schemaSet$ != null) {
|
|
1158
1157
|
if (validateSchema) {
|
|
1159
1158
|
extendContext({
|
|
1160
|
-
[VALIDATE_FN]: (
|
|
1159
|
+
[VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
|
|
1161
1160
|
});
|
|
1162
1161
|
}
|
|
1163
1162
|
setValidationFn(() => []);
|
|
@@ -1165,10 +1164,9 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
|
1165
1164
|
},
|
|
1166
1165
|
async onContextBuilding({ context, extendContext, breakContextBuilding }) {
|
|
1167
1166
|
// If schemaSet promise is still ongoing
|
|
1168
|
-
if (
|
|
1169
|
-
const schema = await schemaSet$;
|
|
1167
|
+
if (context[VALIDATE_FN]) {
|
|
1170
1168
|
const validateFn = context[VALIDATE_FN];
|
|
1171
|
-
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(
|
|
1169
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn();
|
|
1172
1170
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1173
1171
|
extendContext({
|
|
1174
1172
|
[VALIDATION_ERRORS]: errors,
|