@envelop/core 2.3.2-alpha-e4ba153.0 → 2.3.2-alpha-b81730b.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.
Files changed (3) hide show
  1. package/index.js +15 -21
  2. package/index.mjs +15 -21
  3. 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
- schemaSet$ = undefined;
1104
+ return schemaObj;
1105
1105
  });
1106
1106
  }
1107
1107
  else {
@@ -1109,29 +1109,28 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
1109
1109
  }
1110
1110
  },
1111
1111
  onValidate({ validateFn, params, setValidationFn, extendContext }) {
1112
- if (schemaSet$) {
1112
+ if (schemaSet$ != null) {
1113
1113
  if (validateSchema) {
1114
1114
  extendContext({
1115
- [VALIDATE_FN]: (schema) => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options),
1115
+ [VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
1116
1116
  });
1117
1117
  }
1118
1118
  setValidationFn(() => []);
1119
1119
  }
1120
1120
  },
1121
- async onContextBuilding({ context, extendContext, breakContextBuilding }) {
1122
- if (context[VALIDATE_FN]) {
1123
- const schema = await schemaSet$;
1124
- const validateFn = context[VALIDATE_FN];
1125
- const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema);
1121
+ onContextBuilding({ context, extendContext, breakContextBuilding }) {
1122
+ var _a;
1123
+ (_a = context[VALIDATE_FN]) === null || _a === void 0 ? void 0 : _a.call(context).then((errors) => {
1126
1124
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
1127
1125
  extendContext({
1128
1126
  [VALIDATION_ERRORS]: errors,
1129
1127
  });
1130
1128
  breakContextBuilding();
1131
1129
  }
1132
- }
1130
+ });
1133
1131
  },
1134
1132
  onExecute({ args: { contextValue }, setResultAndStopExecution }) {
1133
+ // If validation errors are set in context
1135
1134
  if (contextValue[VALIDATION_ERRORS]) {
1136
1135
  setResultAndStopExecution({
1137
1136
  errors: contextValue[VALIDATION_ERRORS],
@@ -1147,8 +1146,7 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
1147
1146
  if (isPromise(schema$)) {
1148
1147
  schemaSet$ = schema$.then(schemaObj => {
1149
1148
  setSchema(schemaObj);
1150
- // Once the schema is completely resolved, we don't need to keep the logic below.
1151
- schemaSet$ = undefined;
1149
+ return schemaObj;
1152
1150
  });
1153
1151
  }
1154
1152
  else {
@@ -1156,29 +1154,25 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
1156
1154
  }
1157
1155
  },
1158
1156
  onValidate({ validateFn, params, setValidationFn, extendContext }) {
1159
- // If schemaSet promise is still ongoing
1160
- if (schemaSet$) {
1157
+ if (schemaSet$ != null) {
1161
1158
  if (validateSchema) {
1162
1159
  extendContext({
1163
- [VALIDATE_FN]: (schema) => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options),
1160
+ [VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
1164
1161
  });
1165
1162
  }
1166
1163
  setValidationFn(() => []);
1167
1164
  }
1168
1165
  },
1169
- async onContextBuilding({ context, extendContext, breakContextBuilding }) {
1170
- // If schemaSet promise is still ongoing
1171
- if (schemaSet$) {
1172
- const schema = await schemaSet$;
1173
- const validateFn = context[VALIDATE_FN];
1174
- const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema);
1166
+ onContextBuilding({ context, extendContext, breakContextBuilding }) {
1167
+ var _a;
1168
+ (_a = context[VALIDATE_FN]) === null || _a === void 0 ? void 0 : _a.call(context).then((errors) => {
1175
1169
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
1176
1170
  extendContext({
1177
1171
  [VALIDATION_ERRORS]: errors,
1178
1172
  });
1179
1173
  breakContextBuilding();
1180
1174
  }
1181
- }
1175
+ });
1182
1176
  },
1183
1177
  onExecute({ args: { contextValue }, setResultAndStopExecution }) {
1184
1178
  // If validation errors are set in context
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
- schemaSet$ = undefined;
1100
+ return schemaObj;
1101
1101
  });
1102
1102
  }
1103
1103
  else {
@@ -1105,29 +1105,28 @@ const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
1105
1105
  }
1106
1106
  },
1107
1107
  onValidate({ validateFn, params, setValidationFn, extendContext }) {
1108
- if (schemaSet$) {
1108
+ if (schemaSet$ != null) {
1109
1109
  if (validateSchema) {
1110
1110
  extendContext({
1111
- [VALIDATE_FN]: (schema) => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options),
1111
+ [VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
1112
1112
  });
1113
1113
  }
1114
1114
  setValidationFn(() => []);
1115
1115
  }
1116
1116
  },
1117
- async onContextBuilding({ context, extendContext, breakContextBuilding }) {
1118
- if (context[VALIDATE_FN]) {
1119
- const schema = await schemaSet$;
1120
- const validateFn = context[VALIDATE_FN];
1121
- const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema);
1117
+ onContextBuilding({ context, extendContext, breakContextBuilding }) {
1118
+ var _a;
1119
+ (_a = context[VALIDATE_FN]) === null || _a === void 0 ? void 0 : _a.call(context).then((errors) => {
1122
1120
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
1123
1121
  extendContext({
1124
1122
  [VALIDATION_ERRORS]: errors,
1125
1123
  });
1126
1124
  breakContextBuilding();
1127
1125
  }
1128
- }
1126
+ });
1129
1127
  },
1130
1128
  onExecute({ args: { contextValue }, setResultAndStopExecution }) {
1129
+ // If validation errors are set in context
1131
1130
  if (contextValue[VALIDATION_ERRORS]) {
1132
1131
  setResultAndStopExecution({
1133
1132
  errors: contextValue[VALIDATION_ERRORS],
@@ -1143,8 +1142,7 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
1143
1142
  if (isPromise(schema$)) {
1144
1143
  schemaSet$ = schema$.then(schemaObj => {
1145
1144
  setSchema(schemaObj);
1146
- // Once the schema is completely resolved, we don't need to keep the logic below.
1147
- schemaSet$ = undefined;
1145
+ return schemaObj;
1148
1146
  });
1149
1147
  }
1150
1148
  else {
@@ -1152,29 +1150,25 @@ const useAsyncSchema = (schema$, validateSchema = true) => {
1152
1150
  }
1153
1151
  },
1154
1152
  onValidate({ validateFn, params, setValidationFn, extendContext }) {
1155
- // If schemaSet promise is still ongoing
1156
- if (schemaSet$) {
1153
+ if (schemaSet$ != null) {
1157
1154
  if (validateSchema) {
1158
1155
  extendContext({
1159
- [VALIDATE_FN]: (schema) => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options),
1156
+ [VALIDATE_FN]: () => schemaSet$.then(schema => validateFn(schema, params.documentAST, params.rules, params.typeInfo, params.options)),
1160
1157
  });
1161
1158
  }
1162
1159
  setValidationFn(() => []);
1163
1160
  }
1164
1161
  },
1165
- async onContextBuilding({ context, extendContext, breakContextBuilding }) {
1166
- // If schemaSet promise is still ongoing
1167
- if (schemaSet$) {
1168
- const schema = await schemaSet$;
1169
- const validateFn = context[VALIDATE_FN];
1170
- const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema);
1162
+ onContextBuilding({ context, extendContext, breakContextBuilding }) {
1163
+ var _a;
1164
+ (_a = context[VALIDATE_FN]) === null || _a === void 0 ? void 0 : _a.call(context).then((errors) => {
1171
1165
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
1172
1166
  extendContext({
1173
1167
  [VALIDATION_ERRORS]: errors,
1174
1168
  });
1175
1169
  breakContextBuilding();
1176
1170
  }
1177
- }
1171
+ });
1178
1172
  },
1179
1173
  onExecute({ args: { contextValue }, setResultAndStopExecution }) {
1180
1174
  // If validation errors are set in context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.3.2-alpha-e4ba153.0",
3
+ "version": "2.3.2-alpha-b81730b.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"