@envelop/core 2.3.2-alpha-3ace273.0 → 2.3.2-alpha-a0c2439.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 +14 -10
- package/index.mjs +14 -10
- package/package.json +1 -1
- package/plugins/use-schema.d.ts +2 -2
package/index.js
CHANGED
|
@@ -1092,7 +1092,7 @@ const useSchema = (schema) => {
|
|
|
1092
1092
|
};
|
|
1093
1093
|
};
|
|
1094
1094
|
const VALIDATE_FN = Symbol('VALIDATE_FN');
|
|
1095
|
-
const useLazyLoadedSchema = (schemaLoader) => {
|
|
1095
|
+
const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
1096
1096
|
let schemaSet$;
|
|
1097
1097
|
return {
|
|
1098
1098
|
onEnveloped({ setSchema, context }) {
|
|
@@ -1108,16 +1108,18 @@ const useLazyLoadedSchema = (schemaLoader) => {
|
|
|
1108
1108
|
},
|
|
1109
1109
|
onValidate({ validateFn, setValidationFn, extendContext }) {
|
|
1110
1110
|
if (schemaSet$) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1111
|
+
if (validateSchema) {
|
|
1112
|
+
extendContext({
|
|
1113
|
+
[VALIDATE_FN]: validateFn,
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1114
1116
|
setValidationFn(() => []);
|
|
1115
1117
|
}
|
|
1116
1118
|
},
|
|
1117
1119
|
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
|
|
1118
1120
|
if (schemaSet$) {
|
|
1119
1121
|
const validateFn = contextValue[VALIDATE_FN];
|
|
1120
|
-
const errors = validateFn(schema, document);
|
|
1122
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema, document);
|
|
1121
1123
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1122
1124
|
setResultAndStopExecution({
|
|
1123
1125
|
errors,
|
|
@@ -1131,7 +1133,7 @@ const useLazyLoadedSchema = (schemaLoader) => {
|
|
|
1131
1133
|
},
|
|
1132
1134
|
};
|
|
1133
1135
|
};
|
|
1134
|
-
const useAsyncSchema = (schema
|
|
1136
|
+
const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
1135
1137
|
let schemaSet$;
|
|
1136
1138
|
return {
|
|
1137
1139
|
onPluginInit({ setSchema }) {
|
|
@@ -1146,16 +1148,18 @@ const useAsyncSchema = (schema$) => {
|
|
|
1146
1148
|
},
|
|
1147
1149
|
onValidate({ validateFn, setValidationFn, extendContext }) {
|
|
1148
1150
|
if (schemaSet$) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1151
|
+
if (validateSchema) {
|
|
1152
|
+
extendContext({
|
|
1153
|
+
[VALIDATE_FN]: validateFn,
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1152
1156
|
setValidationFn(() => []);
|
|
1153
1157
|
}
|
|
1154
1158
|
},
|
|
1155
1159
|
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
|
|
1156
1160
|
if (schemaSet$) {
|
|
1157
1161
|
const validateFn = contextValue[VALIDATE_FN];
|
|
1158
|
-
const errors = validateFn(schema, document);
|
|
1162
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema, document);
|
|
1159
1163
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1160
1164
|
setResultAndStopExecution({
|
|
1161
1165
|
errors,
|
package/index.mjs
CHANGED
|
@@ -1088,7 +1088,7 @@ const useSchema = (schema) => {
|
|
|
1088
1088
|
};
|
|
1089
1089
|
};
|
|
1090
1090
|
const VALIDATE_FN = Symbol('VALIDATE_FN');
|
|
1091
|
-
const useLazyLoadedSchema = (schemaLoader) => {
|
|
1091
|
+
const useLazyLoadedSchema = (schemaLoader, validateSchema = true) => {
|
|
1092
1092
|
let schemaSet$;
|
|
1093
1093
|
return {
|
|
1094
1094
|
onEnveloped({ setSchema, context }) {
|
|
@@ -1104,16 +1104,18 @@ const useLazyLoadedSchema = (schemaLoader) => {
|
|
|
1104
1104
|
},
|
|
1105
1105
|
onValidate({ validateFn, setValidationFn, extendContext }) {
|
|
1106
1106
|
if (schemaSet$) {
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1107
|
+
if (validateSchema) {
|
|
1108
|
+
extendContext({
|
|
1109
|
+
[VALIDATE_FN]: validateFn,
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1110
1112
|
setValidationFn(() => []);
|
|
1111
1113
|
}
|
|
1112
1114
|
},
|
|
1113
1115
|
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
|
|
1114
1116
|
if (schemaSet$) {
|
|
1115
1117
|
const validateFn = contextValue[VALIDATE_FN];
|
|
1116
|
-
const errors = validateFn(schema, document);
|
|
1118
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema, document);
|
|
1117
1119
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1118
1120
|
setResultAndStopExecution({
|
|
1119
1121
|
errors,
|
|
@@ -1127,7 +1129,7 @@ const useLazyLoadedSchema = (schemaLoader) => {
|
|
|
1127
1129
|
},
|
|
1128
1130
|
};
|
|
1129
1131
|
};
|
|
1130
|
-
const useAsyncSchema = (schema
|
|
1132
|
+
const useAsyncSchema = (schema$, validateSchema = true) => {
|
|
1131
1133
|
let schemaSet$;
|
|
1132
1134
|
return {
|
|
1133
1135
|
onPluginInit({ setSchema }) {
|
|
@@ -1142,16 +1144,18 @@ const useAsyncSchema = (schema$) => {
|
|
|
1142
1144
|
},
|
|
1143
1145
|
onValidate({ validateFn, setValidationFn, extendContext }) {
|
|
1144
1146
|
if (schemaSet$) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1147
|
+
if (validateSchema) {
|
|
1148
|
+
extendContext({
|
|
1149
|
+
[VALIDATE_FN]: validateFn,
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1148
1152
|
setValidationFn(() => []);
|
|
1149
1153
|
}
|
|
1150
1154
|
},
|
|
1151
1155
|
onExecute({ args: { schema, document, contextValue }, setResultAndStopExecution }) {
|
|
1152
1156
|
if (schemaSet$) {
|
|
1153
1157
|
const validateFn = contextValue[VALIDATE_FN];
|
|
1154
|
-
const errors = validateFn(schema, document);
|
|
1158
|
+
const errors = validateFn === null || validateFn === void 0 ? void 0 : validateFn(schema, document);
|
|
1155
1159
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
1156
1160
|
setResultAndStopExecution({
|
|
1157
1161
|
errors,
|
package/package.json
CHANGED
package/plugins/use-schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { DefaultContext, Maybe, Plugin, PromiseOrValue } from '@envelop/types';
|
|
3
3
|
export declare const useSchema: (schema: GraphQLSchema) => Plugin;
|
|
4
|
-
export declare const useLazyLoadedSchema: (schemaLoader: (context: Maybe<DefaultContext>) => PromiseOrValue<GraphQLSchema
|
|
5
|
-
export declare const useAsyncSchema: (schema$: PromiseOrValue<GraphQLSchema
|
|
4
|
+
export declare const useLazyLoadedSchema: (schemaLoader: (context: Maybe<DefaultContext>) => PromiseOrValue<GraphQLSchema>, validateSchema?: boolean) => Plugin;
|
|
5
|
+
export declare const useAsyncSchema: (schema$: PromiseOrValue<GraphQLSchema>, validateSchema?: boolean) => Plugin;
|