@webiny/api-headless-cms 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.aa00eecd97
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/context.d.ts +5 -2
- package/context.js +61 -8
- package/context.js.map +1 -1
- package/crud/contentEntry/markLockedFields.d.ts +1 -1
- package/crud/contentEntry/markLockedFields.js +17 -4
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js +40 -9
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +72 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/crud/contentEntry.crud.d.ts +8 -5
- package/crud/contentEntry.crud.js +1081 -841
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/beforeCreate.d.ts +2 -3
- package/crud/contentModel/beforeCreate.js +43 -81
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.d.ts +1 -1
- package/crud/contentModel/beforeDelete.js +1 -5
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.d.ts +2 -4
- package/crud/contentModel/beforeUpdate.js +33 -5
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
- package/crud/contentModel/createFieldStorageId.js +4 -1
- package/crud/contentModel/createFieldStorageId.js.map +1 -1
- package/crud/contentModel/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -0
- package/crud/contentModel/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.js.map +1 -0
- package/crud/contentModel/validateModel.d.ts +4 -4
- package/crud/contentModel/validateModel.js +6 -3
- package/crud/contentModel/validateModel.js.map +1 -1
- package/crud/contentModel/validateModelFields.d.ts +4 -4
- package/crud/contentModel/validateModelFields.js +123 -88
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/crud/contentModel.crud.js +369 -273
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/validation.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/crud/contentModelGroup.crud.js +189 -172
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/settings.crud.d.ts +1 -1
- package/crud/settings.crud.js +5 -10
- package/crud/settings.crud.js.map +1 -1
- package/crud/system.crud.js +0 -60
- package/crud/system.crud.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +11 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +203 -0
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -0
- package/fieldConverters/index.d.ts +2 -1
- package/fieldConverters/index.js +2 -1
- package/fieldConverters/index.js.map +1 -1
- package/graphql/buildSchemaPlugins.d.ts +8 -3
- package/graphql/buildSchemaPlugins.js +3 -7
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.js +6 -104
- package/graphql/graphQLHandlerFactory.js.map +1 -1
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +1 -3
- package/graphql/index.js +2 -39
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseContentSchema.d.ts +6 -2
- package/graphql/schema/baseContentSchema.js +9 -11
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +68 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +6 -2
- package/graphql/schema/contentEntries.js +116 -65
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.d.ts +6 -2
- package/graphql/schema/contentModelGroups.js +14 -10
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.d.ts +6 -2
- package/graphql/schema/contentModels.js +60 -8
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +2 -2
- package/graphql/schema/createFieldResolvers.js +18 -13
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
- package/graphql/schema/createFieldTypePluginRecords.js +13 -0
- package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +1 -1
- package/graphql/schema/createManageResolvers.js +37 -17
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.d.ts +3 -0
- package/graphql/schema/createManageSDL.js +81 -63
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.js +3 -7
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.js +8 -7
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.d.ts +3 -0
- package/graphql/schema/createReadSDL.js +47 -36
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
- package/graphql/schema/resolvers/commonFieldResolvers.js +2 -1
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +13 -3
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +20 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
- package/graphql/schema/schemaPlugins.d.ts +8 -3
- package/graphql/schema/schemaPlugins.js +55 -52
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.js +55 -74
- package/graphql/system.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +2 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js +243 -0
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +3 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +63 -0
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -0
- package/graphqlFields/dynamicZone/index.d.ts +2 -0
- package/graphqlFields/dynamicZone/index.js +19 -0
- package/graphqlFields/dynamicZone/index.js.map +1 -0
- package/graphqlFields/index.d.ts +1 -1
- package/graphqlFields/index.js +2 -1
- package/graphqlFields/index.js.map +1 -1
- package/graphqlFields/number.js +4 -0
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js +131 -68
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +70 -56
- package/graphqlFields/ref.js.map +1 -1
- package/index.d.ts +5 -3
- package/index.js +27 -8
- package/index.js.map +1 -1
- package/package.json +40 -41
- package/plugins/CmsGraphQLSchemaPlugin.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
- package/plugins/CmsModelPlugin.d.ts +21 -3
- package/plugins/CmsModelPlugin.js +28 -2
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +11 -11
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +33 -0
- package/plugins/index.js.map +1 -1
- package/storage/object.js +4 -2
- package/storage/object.js.map +1 -1
- package/types.d.ts +436 -149
- package/types.js +74 -8
- package/types.js.map +1 -1
- package/utils/converters/ConverterCollection.js +5 -2
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
- package/utils/converters/valueKeyStorageConverter.js +26 -20
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.d.ts +16 -0
- package/utils/createTypeFromFields.js +66 -0
- package/utils/createTypeFromFields.js.map +1 -0
- package/utils/createTypeName.d.ts +0 -2
- package/utils/createTypeName.js +4 -11
- package/utils/createTypeName.js.map +1 -1
- package/utils/entryStorage.js +14 -11
- package/utils/entryStorage.js.map +1 -1
- package/utils/getBaseFieldType.d.ts +2 -0
- package/utils/getBaseFieldType.js +10 -0
- package/utils/getBaseFieldType.js.map +1 -0
- package/utils/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.js.map +1 -0
- package/utils/getEntryTitle.d.ts +1 -1
- package/utils/getEntryTitle.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.d.ts +4 -7
- package/utils/getSchemaFromFieldPlugins.js +22 -14
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.js.map +1 -0
- package/utils/ownership.d.ts +3 -3
- package/utils/ownership.js.map +1 -1
- package/utils/renderFields.d.ts +4 -2
- package/utils/renderFields.js +12 -3
- package/utils/renderFields.js.map +1 -1
- package/utils/renderGetFilterFields.d.ts +2 -2
- package/utils/renderGetFilterFields.js +9 -19
- package/utils/renderGetFilterFields.js.map +1 -1
- package/utils/renderInputFields.d.ts +4 -2
- package/utils/renderInputFields.js +19 -6
- package/utils/renderInputFields.js.map +1 -1
- package/utils/renderListFilterFields.d.ts +2 -1
- package/utils/renderListFilterFields.js +12 -21
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.d.ts +9 -5
- package/utils/renderSortEnum.js +23 -5
- package/utils/renderSortEnum.js.map +1 -1
- package/validators/dynamicZone.d.ts +2 -0
- package/validators/dynamicZone.js +20 -0
- package/validators/dynamicZone.js.map +1 -0
- package/validators/index.js +2 -1
- package/validators/index.js.map +1 -1
- package/crud/contentModel/createFieldModels.d.ts +0 -2
- package/crud/contentModel/createFieldModels.js +0 -20
- package/crud/contentModel/createFieldModels.js.map +0 -1
- package/crud/contentModel/fieldIdValidation.d.ts +0 -1
- package/crud/contentModel/fieldIdValidation.js +0 -20
- package/crud/contentModel/fieldIdValidation.js.map +0 -1
- package/crud/contentModel/idValidation.d.ts +0 -1
- package/crud/contentModel/idValidation.js +0 -17
- package/crud/contentModel/idValidation.js.map +0 -1
- package/crud/contentModel/models.d.ts +0 -4
- package/crud/contentModel/models.js +0 -173
- package/crud/contentModel/models.js.map +0 -1
- package/crud/contentModel/systemFields.d.ts +0 -1
- package/crud/contentModel/systemFields.js +0 -8
- package/crud/contentModel/systemFields.js.map +0 -1
- package/crud/index.d.ts +0 -6
- package/crud/index.js +0 -69
- package/crud/index.js.map +0 -1
- package/graphql/schema/resolvers/manage/resolveRequestChanges.d.ts +0 -7
- package/graphql/schema/resolvers/manage/resolveRequestChanges.js +0 -21
- package/graphql/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
- package/graphql/schema/resolvers/manage/resolveRequestReview.d.ts +0 -7
- package/graphql/schema/resolvers/manage/resolveRequestReview.js +0 -21
- package/graphql/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
- package/upgrades/5.33.0/index.d.ts +0 -3
- package/upgrades/5.33.0/index.js +0 -159
- package/upgrades/5.33.0/index.js.map +0 -1
- package/upgrades/index.d.ts +0 -1
- package/upgrades/index.js +0 -9
- package/upgrades/index.js.map +0 -1
- package/utils/filterModelFields.d.ts +0 -16
- package/utils/filterModelFields.js +0 -71
- package/utils/filterModelFields.js.map +0 -1
- package/utils/pluralizedTypeName.d.ts +0 -1
- package/utils/pluralizedTypeName.js +0 -20
- package/utils/pluralizedTypeName.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateSchema","params","context","models","generatedSchemaPlugins","buildSchemaPlugins","ex","console","log","plugins","register","schemaPlugins","byType","CmsGraphQLSchemaPlugin","type","createExecutableSchema"],"sources":["generateSchema.ts"],"sourcesContent":["import { CmsContext, CmsModel } from \"~/types\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { createExecutableSchema } from \"./createExecutableSchema\";\nimport { GraphQLSchema } from \"graphql/type\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface GenerateSchemaParams {\n context: CmsContext;\n models: CmsModel[];\n}\nexport const generateSchema = async (params: GenerateSchemaParams): Promise<GraphQLSchema> => {\n const { context, models } = params;\n\n let generatedSchemaPlugins: CmsGraphQLSchemaPlugin[] = [];\n try {\n generatedSchemaPlugins = await buildSchemaPlugins({ context, models });\n } catch (ex) {\n console.log(`Error while building schema plugins.`);\n throw ex;\n }\n\n context.plugins.register(generatedSchemaPlugins);\n\n const schemaPlugins = context.plugins.byType<CmsGraphQLSchemaPlugin>(\n CmsGraphQLSchemaPlugin.type\n );\n return createExecutableSchema({\n plugins: schemaPlugins\n });\n};\n"],"mappings":";;;;;;AACA;AACA;AAEA;AAMO,MAAMA,cAAc,GAAG,MAAOC,MAA4B,IAA6B;EAC1F,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAElC,IAAIG,sBAAgD,GAAG,EAAE;EACzD,IAAI;IACAA,sBAAsB,GAAG,MAAM,IAAAC,sCAAkB,EAAC;MAAEH,OAAO;MAAEC;IAAO,CAAC,CAAC;EAC1E,CAAC,CAAC,OAAOG,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAE,sCAAqC,CAAC;IACnD,MAAMF,EAAE;EACZ;EAEAJ,OAAO,CAACO,OAAO,CAACC,QAAQ,CAACN,sBAAsB,CAAC;EAEhD,MAAMO,aAAa,GAAGT,OAAO,CAACO,OAAO,CAACG,MAAM,CACxCC,+BAAsB,CAACC,IAAI,CAC9B;EACD,OAAO,IAAAC,8CAAsB,EAAC;IAC1BN,OAAO,EAAEE;EACb,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiEndpoint, CmsContext } from "../types";
|
|
2
|
+
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
|
+
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
|
+
import { GraphQLSchema } from "graphql";
|
|
5
|
+
interface GetSchemaParams {
|
|
6
|
+
context: CmsContext;
|
|
7
|
+
type: ApiEndpoint;
|
|
8
|
+
getLastModifiedTime: () => Promise<Date | null>;
|
|
9
|
+
getTenant: () => Tenant;
|
|
10
|
+
getLocale: () => I18NLocale;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Gets an existing schema or rewrites existing one or creates a completely new one
|
|
14
|
+
* depending on the schemaId created from type and locale parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare const getSchema: (params: GetSchemaParams) => Promise<GraphQLSchema>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getSchema = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _codeFrame = _interopRequireDefault(require("code-frame"));
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
var _generateSchema = require("./generateSchema");
|
|
12
|
+
// @ts-ignore `code-frame` has no types
|
|
13
|
+
|
|
14
|
+
const schemaList = new Map();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Method generates cache ID based on:
|
|
18
|
+
* - tenant
|
|
19
|
+
* - endpoint type
|
|
20
|
+
* - locale
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const generateCacheId = params => {
|
|
24
|
+
const {
|
|
25
|
+
getTenant,
|
|
26
|
+
type,
|
|
27
|
+
getLocale
|
|
28
|
+
} = params;
|
|
29
|
+
return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join("#");
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Method generates cache key based on last model change time.
|
|
33
|
+
* Or sets "unknown" - possible when no models in database.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const generateCacheKey = async params => {
|
|
37
|
+
const {
|
|
38
|
+
getLastModifiedTime
|
|
39
|
+
} = params;
|
|
40
|
+
const lastModelChange = await getLastModifiedTime();
|
|
41
|
+
if (!lastModelChange) {
|
|
42
|
+
return "unknown";
|
|
43
|
+
}
|
|
44
|
+
return lastModelChange.toISOString();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Gets an existing schema or rewrites existing one or creates a completely new one
|
|
49
|
+
* depending on the schemaId created from type and locale parameters
|
|
50
|
+
*/
|
|
51
|
+
const getSchema = async params => {
|
|
52
|
+
const {
|
|
53
|
+
context
|
|
54
|
+
} = params;
|
|
55
|
+
const cacheId = generateCacheId(params);
|
|
56
|
+
const cacheKey = await generateCacheKey(params);
|
|
57
|
+
const cachedSchema = schemaList.get(cacheId);
|
|
58
|
+
if ((cachedSchema === null || cachedSchema === void 0 ? void 0 : cachedSchema.key) === cacheKey) {
|
|
59
|
+
return cachedSchema.schema;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* We need all the API models.
|
|
64
|
+
* Private models are hidden in the GraphQL, so filter them out.
|
|
65
|
+
*/
|
|
66
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
67
|
+
return (await context.cms.listModels()).filter(model => {
|
|
68
|
+
return model.isPrivate !== true;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const schema = await (0, _generateSchema.generateSchema)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
73
|
+
models
|
|
74
|
+
}));
|
|
75
|
+
schemaList.set(cacheId, {
|
|
76
|
+
key: cacheKey,
|
|
77
|
+
schema
|
|
78
|
+
});
|
|
79
|
+
return schema;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (!Array.isArray(err.locations)) {
|
|
82
|
+
throw new _error.default({
|
|
83
|
+
message: err.message,
|
|
84
|
+
code: err.code || "INVALID_GRAPHQL_SCHEMA_LOCATIONS",
|
|
85
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, err.data || {}), {}, {
|
|
86
|
+
locations: err.locations
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const [location] = err.locations;
|
|
91
|
+
throw new _error.default({
|
|
92
|
+
code: "INVALID_GRAPHQL_SCHEMA",
|
|
93
|
+
message: err.message,
|
|
94
|
+
data: {
|
|
95
|
+
invalidSegment: (0, _codeFrame.default)(err.source.body, location.line, location.column, {
|
|
96
|
+
frameSize: 15
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.getSchema = getSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["schemaList","Map","generateCacheId","params","getTenant","type","getLocale","id","code","join","generateCacheKey","getLastModifiedTime","lastModelChange","toISOString","getSchema","context","cacheId","cacheKey","cachedSchema","get","key","schema","models","security","withoutAuthorization","cms","listModels","filter","model","isPrivate","generateSchema","set","err","Array","isArray","locations","WebinyError","message","data","location","invalidSegment","codeFrame","source","body","line","column","frameSize"],"sources":["getSchema.ts"],"sourcesContent":["// @ts-ignore `code-frame` has no types\nimport codeFrame from \"code-frame\";\nimport WebinyError from \"@webiny/error\";\nimport { generateSchema } from \"./generateSchema\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { GraphQLSchema } from \"graphql\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\n\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n getLastModifiedTime: () => Promise<Date | null>;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nconst schemaList = new Map<string, SchemaCache>();\n\n/**\n * Method generates cache ID based on:\n * - tenant\n * - endpoint type\n * - locale\n */\ntype GenerateCacheIdParams = Pick<GetSchemaParams, \"getTenant\" | \"getLocale\" | \"type\">;\nconst generateCacheId = (params: GenerateCacheIdParams): string => {\n const { getTenant, type, getLocale } = params;\n return [`tenant:${getTenant().id}`, `endpoint:${type}`, `locale:${getLocale().code}`].join(\"#\");\n};\n/**\n * Method generates cache key based on last model change time.\n * Or sets \"unknown\" - possible when no models in database.\n */\ntype GenerateCacheKeyParams = Pick<GetSchemaParams, \"getLastModifiedTime\">;\nconst generateCacheKey = async (params: GenerateCacheKeyParams): Promise<string> => {\n const { getLastModifiedTime } = params;\n const lastModelChange = await getLastModifiedTime();\n if (!lastModelChange) {\n return \"unknown\";\n }\n return lastModelChange.toISOString();\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nexport const getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = params;\n\n const cacheId = generateCacheId(params);\n\n const cacheKey = await generateCacheKey(params);\n const cachedSchema = schemaList.get(cacheId);\n if (cachedSchema?.key === cacheKey) {\n return cachedSchema.schema;\n }\n\n /**\n * We need all the API models.\n * Private models are hidden in the GraphQL, so filter them out.\n */\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return model.isPrivate !== true;\n });\n });\n try {\n const schema = await generateSchema({\n ...params,\n models\n });\n schemaList.set(cacheId, {\n key: cacheKey,\n schema\n });\n return schema;\n } catch (err) {\n if (!Array.isArray(err.locations)) {\n throw new WebinyError({\n message: err.message,\n code: err.code || \"INVALID_GRAPHQL_SCHEMA_LOCATIONS\",\n data: {\n ...(err.data || {}),\n locations: err.locations\n }\n });\n }\n const [location] = err.locations;\n\n throw new WebinyError({\n code: \"INVALID_GRAPHQL_SCHEMA\",\n message: err.message,\n data: {\n invalidSegment: codeFrame(err.source.body, location.line, location.column, {\n frameSize: 15\n })\n }\n });\n }\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AAHA;;AAsBA,MAAMA,UAAU,GAAG,IAAIC,GAAG,EAAuB;;AAEjD;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,eAAe,GAAIC,MAA6B,IAAa;EAC/D,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAC7C,OAAO,CAAE,UAASC,SAAS,EAAE,CAACG,EAAG,EAAC,EAAG,YAAWF,IAAK,EAAC,EAAG,UAASC,SAAS,EAAE,CAACE,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;AACnG,CAAC;AACD;AACA;AACA;AACA;;AAEA,MAAMC,gBAAgB,GAAG,MAAOP,MAA8B,IAAsB;EAChF,MAAM;IAAEQ;EAAoB,CAAC,GAAGR,MAAM;EACtC,MAAMS,eAAe,GAAG,MAAMD,mBAAmB,EAAE;EACnD,IAAI,CAACC,eAAe,EAAE;IAClB,OAAO,SAAS;EACpB;EACA,OAAOA,eAAe,CAACC,WAAW,EAAE;AACxC,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMC,SAAS,GAAG,MAAOX,MAAuB,IAA6B;EAChF,MAAM;IAAEY;EAAQ,CAAC,GAAGZ,MAAM;EAE1B,MAAMa,OAAO,GAAGd,eAAe,CAACC,MAAM,CAAC;EAEvC,MAAMc,QAAQ,GAAG,MAAMP,gBAAgB,CAACP,MAAM,CAAC;EAC/C,MAAMe,YAAY,GAAGlB,UAAU,CAACmB,GAAG,CAACH,OAAO,CAAC;EAC5C,IAAI,CAAAE,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEE,GAAG,MAAKH,QAAQ,EAAE;IAChC,OAAOC,YAAY,CAACG,MAAM;EAC9B;;EAEA;AACJ;AACA;AACA;EACI,MAAMC,MAAM,GAAG,MAAMP,OAAO,CAACQ,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACnE,OAAO,CAAC,MAAMT,OAAO,CAACU,GAAG,CAACC,UAAU,EAAE,EAAEC,MAAM,CAACC,KAAK,IAAI;MACpD,OAAOA,KAAK,CAACC,SAAS,KAAK,IAAI;IACnC,CAAC,CAAC;EACN,CAAC,CAAC;EACF,IAAI;IACA,MAAMR,MAAM,GAAG,MAAM,IAAAS,8BAAc,8DAC5B3B,MAAM;MACTmB;IAAM,GACR;IACFtB,UAAU,CAAC+B,GAAG,CAACf,OAAO,EAAE;MACpBI,GAAG,EAAEH,QAAQ;MACbI;IACJ,CAAC,CAAC;IACF,OAAOA,MAAM;EACjB,CAAC,CAAC,OAAOW,GAAG,EAAE;IACV,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,GAAG,CAACG,SAAS,CAAC,EAAE;MAC/B,MAAM,IAAIC,cAAW,CAAC;QAClBC,OAAO,EAAEL,GAAG,CAACK,OAAO;QACpB7B,IAAI,EAAEwB,GAAG,CAACxB,IAAI,IAAI,kCAAkC;QACpD8B,IAAI,8DACIN,GAAG,CAACM,IAAI,IAAI,CAAC,CAAC;UAClBH,SAAS,EAAEH,GAAG,CAACG;QAAS;MAEhC,CAAC,CAAC;IACN;IACA,MAAM,CAACI,QAAQ,CAAC,GAAGP,GAAG,CAACG,SAAS;IAEhC,MAAM,IAAIC,cAAW,CAAC;MAClB5B,IAAI,EAAE,wBAAwB;MAC9B6B,OAAO,EAAEL,GAAG,CAACK,OAAO;MACpBC,IAAI,EAAE;QACFE,cAAc,EAAE,IAAAC,kBAAS,EAACT,GAAG,CAACU,MAAM,CAACC,IAAI,EAAEJ,QAAQ,CAACK,IAAI,EAAEL,QAAQ,CAACM,MAAM,EAAE;UACvEC,SAAS,EAAE;QACf,CAAC;MACL;IACJ,CAAC,CAAC;EACN;AACJ,CAAC;AAAC"}
|
|
@@ -5,124 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.graphQLHandlerFactory = void 0;
|
|
8
|
-
var _schema = require("@graphql-tools/schema");
|
|
9
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
10
8
|
var _debugPlugins = _interopRequireDefault(require("@webiny/handler-graphql/debugPlugins"));
|
|
11
|
-
var _processRequestBody = _interopRequireDefault(require("@webiny/handler-graphql/processRequestBody"));
|
|
12
|
-
var _buildSchemaPlugins = require("./buildSchemaPlugins");
|
|
13
|
-
var _plugins = require("@webiny/handler-graphql/plugins");
|
|
14
9
|
var _handler = require("@webiny/handler");
|
|
15
|
-
|
|
16
|
-
const generateCacheKey = async args => {
|
|
17
|
-
const {
|
|
18
|
-
context,
|
|
19
|
-
locale,
|
|
20
|
-
type
|
|
21
|
-
} = args;
|
|
22
|
-
const lastModelChange = await context.cms.getModelLastChange();
|
|
23
|
-
return [locale.code, type, lastModelChange.toISOString()].join("#");
|
|
24
|
-
};
|
|
25
|
-
const generateSchema = async args => {
|
|
26
|
-
const {
|
|
27
|
-
context
|
|
28
|
-
} = args;
|
|
29
|
-
context.plugins.register(await (0, _buildSchemaPlugins.buildSchemaPlugins)(context));
|
|
30
|
-
/**
|
|
31
|
-
* Really hard to type this to satisfy the makeExecutableSchema
|
|
32
|
-
*/
|
|
33
|
-
// TODO @ts-refactor
|
|
34
|
-
const typeDefs = [];
|
|
35
|
-
const resolvers = [];
|
|
36
|
-
|
|
37
|
-
// Get schema definitions from plugins
|
|
38
|
-
const schemaPlugins = context.plugins.byType(_plugins.GraphQLSchemaPlugin.type);
|
|
39
|
-
for (const pl of schemaPlugins) {
|
|
40
|
-
typeDefs.push(pl.schema.typeDefs);
|
|
41
|
-
resolvers.push(pl.schema.resolvers);
|
|
42
|
-
}
|
|
43
|
-
return (0, _schema.makeExecutableSchema)({
|
|
44
|
-
typeDefs,
|
|
45
|
-
resolvers
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Gets an existing schema or rewrites existing one or creates a completely new one
|
|
51
|
-
* depending on the schemaId created from type and locale parameters
|
|
52
|
-
*/
|
|
53
|
-
const getSchema = async params => {
|
|
54
|
-
const {
|
|
55
|
-
context,
|
|
56
|
-
type,
|
|
57
|
-
locale
|
|
58
|
-
} = params;
|
|
59
|
-
const tenantId = context.tenancy.getCurrentTenant().id;
|
|
60
|
-
const id = `${tenantId}#${type}#${locale.code}`;
|
|
61
|
-
const cacheKey = await generateCacheKey(params);
|
|
62
|
-
if (!schemaList.has(id)) {
|
|
63
|
-
const schema = await generateSchema(params);
|
|
64
|
-
schemaList.set(id, {
|
|
65
|
-
key: cacheKey,
|
|
66
|
-
schema
|
|
67
|
-
});
|
|
68
|
-
return schema;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Safe to cast because check was done few lines up.
|
|
72
|
-
*/
|
|
73
|
-
const cache = schemaList.get(id);
|
|
74
|
-
if (cache.key === cacheKey) {
|
|
75
|
-
return cache.schema;
|
|
76
|
-
}
|
|
77
|
-
const schema = await generateSchema(params);
|
|
78
|
-
schemaList.set(id, {
|
|
79
|
-
key: cacheKey,
|
|
80
|
-
schema
|
|
81
|
-
});
|
|
82
|
-
return schema;
|
|
83
|
-
};
|
|
84
|
-
const checkEndpointAccess = async context => {
|
|
85
|
-
const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);
|
|
86
|
-
if (!permission) {
|
|
87
|
-
throw new _apiSecurity.NotAuthorizedError({
|
|
88
|
-
data: {
|
|
89
|
-
reason: `Not allowed to access "${context.cms.type}" endpoint.`
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
10
|
+
var _handleRequest = require("./handleRequest");
|
|
94
11
|
const cmsRoutes = new _handler.RoutePlugin(({
|
|
95
12
|
onPost,
|
|
96
13
|
onOptions,
|
|
97
14
|
context
|
|
98
15
|
}) => {
|
|
99
16
|
onPost("/cms/:type(^manage|preview|read$)/:locale", async (request, reply) => {
|
|
100
|
-
|
|
101
|
-
await checkEndpointAccess(context);
|
|
102
|
-
} catch (ex) {
|
|
103
|
-
return reply.code(401).send({
|
|
104
|
-
data: null,
|
|
105
|
-
error: {
|
|
106
|
-
message: ex.message || "Not authorized!",
|
|
107
|
-
code: ex.code || "SECURITY_NOT_AUTHORIZED",
|
|
108
|
-
data: ex.data || null,
|
|
109
|
-
stack: null
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
const schema = await getSchema({
|
|
17
|
+
return (0, _handleRequest.handleRequest)({
|
|
114
18
|
context,
|
|
115
|
-
|
|
116
|
-
|
|
19
|
+
request,
|
|
20
|
+
reply
|
|
117
21
|
});
|
|
118
|
-
const body = request.body;
|
|
119
|
-
const result = await (0, _processRequestBody.default)(body, schema, context);
|
|
120
|
-
return reply.code(200).send(result);
|
|
121
22
|
});
|
|
122
23
|
onOptions("/cms/:type(^manage|preview|read$)/:locale", async (_, reply) => {
|
|
123
|
-
return reply.
|
|
24
|
+
return reply.status(204).send({}).hijack();
|
|
124
25
|
});
|
|
125
26
|
});
|
|
27
|
+
cmsRoutes.name = "headless-cms.graphql.route.default";
|
|
126
28
|
const graphQLHandlerFactory = ({
|
|
127
29
|
debug
|
|
128
30
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["cmsRoutes","RoutePlugin","onPost","onOptions","context","request","reply","handleRequest","_","status","send","hijack","name","graphQLHandlerFactory","debug","debugPlugins","type"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport { CmsContext } from \"~/types\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport { handleRequest } from \"./handleRequest\";\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n return handleRequest({ context, request, reply });\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.status(204).send({}).hijack();\n });\n});\n\ncmsRoutes.name = \"headless-cms.graphql.route.default\";\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;AAAA;AAGA;AACA;AAMA,MAAMA,SAAS,GAAG,IAAIC,oBAAW,CAAa,CAAC;EAAEC,MAAM;EAAEC,SAAS;EAAEC;AAAQ,CAAC,KAAK;EAC9EF,MAAM,CAAC,2CAA2C,EAAE,OAAOG,OAAO,EAAEC,KAAK,KAAK;IAC1E,OAAO,IAAAC,4BAAa,EAAC;MAAEH,OAAO;MAAEC,OAAO;MAAEC;IAAM,CAAC,CAAC;EACrD,CAAC,CAAC;EAEFH,SAAS,CAAC,2CAA2C,EAAE,OAAOK,CAAC,EAAEF,KAAK,KAAK;IACvE,OAAOA,KAAK,CAACG,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC,CAACC,MAAM,EAAE;EAC9C,CAAC,CAAC;AACN,CAAC,CAAC;AAEFX,SAAS,CAACY,IAAI,GAAG,oCAAoC;AAE9C,MAAMC,qBAAqB,GAAG,CAAC;EAAEC;AAAmC,CAAC,KAAuB;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAY,GAAE,GAAG,EAAE,CAAC,EAChCf,SAAS,EACT;IACIgB,IAAI,EAAE;EACV,CAAC,CACJ;AACL,CAAC;AAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CmsContext } from "../types";
|
|
2
|
+
import { Reply, Request } from "@webiny/handler/types";
|
|
3
|
+
export interface HandleRequestParams {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
request: Request;
|
|
6
|
+
reply: Reply;
|
|
7
|
+
}
|
|
8
|
+
export interface HandleRequest {
|
|
9
|
+
(params: HandleRequestParams): Promise<Reply>;
|
|
10
|
+
}
|
|
11
|
+
export declare const handleRequest: HandleRequest;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleRequest = void 0;
|
|
7
|
+
var _checkEndpointAccess = require("./checkEndpointAccess");
|
|
8
|
+
var _createRequestBody = require("./createRequestBody");
|
|
9
|
+
var _formatErrorPayload = require("./formatErrorPayload");
|
|
10
|
+
var _getSchema = require("./getSchema");
|
|
11
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
12
|
+
const handleRequest = async params => {
|
|
13
|
+
const {
|
|
14
|
+
context,
|
|
15
|
+
request,
|
|
16
|
+
reply
|
|
17
|
+
} = params;
|
|
18
|
+
try {
|
|
19
|
+
await (0, _checkEndpointAccess.checkEndpointAccess)(context);
|
|
20
|
+
} catch (ex) {
|
|
21
|
+
return reply.code(401).send({
|
|
22
|
+
data: null,
|
|
23
|
+
error: {
|
|
24
|
+
message: ex.message || "Not authorized!",
|
|
25
|
+
code: ex.code || "SECURITY_NOT_AUTHORIZED",
|
|
26
|
+
data: ex.data || null,
|
|
27
|
+
stack: null
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const getTenant = () => {
|
|
32
|
+
return context.tenancy.getCurrentTenant();
|
|
33
|
+
};
|
|
34
|
+
const getLocale = () => {
|
|
35
|
+
return context.cms.getLocale();
|
|
36
|
+
};
|
|
37
|
+
const getLastModifiedTime = async () => {
|
|
38
|
+
return context.cms.getModelLastChange();
|
|
39
|
+
};
|
|
40
|
+
const schema = await context.benchmark.measure("headlessCms.graphql.getSchema", async () => {
|
|
41
|
+
try {
|
|
42
|
+
return await (0, _getSchema.getSchema)({
|
|
43
|
+
context,
|
|
44
|
+
getTenant,
|
|
45
|
+
getLastModifiedTime,
|
|
46
|
+
getLocale,
|
|
47
|
+
type: context.cms.type
|
|
48
|
+
});
|
|
49
|
+
} catch (ex) {
|
|
50
|
+
console.error(`Error while generating the schema.`);
|
|
51
|
+
console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
|
|
52
|
+
throw ex;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const body = await context.benchmark.measure("headlessCms.graphql.createRequestBody", async () => {
|
|
56
|
+
try {
|
|
57
|
+
return (0, _createRequestBody.createRequestBody)(request.body);
|
|
58
|
+
} catch (ex) {
|
|
59
|
+
console.error(`Error while creating the body request.`);
|
|
60
|
+
console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
|
|
61
|
+
throw ex;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* We need to store the processRequestBody result in a variable and output it after the measurement.
|
|
67
|
+
* Otherwise, the measurement will not be shown in the output.
|
|
68
|
+
*/
|
|
69
|
+
let result = null;
|
|
70
|
+
await context.benchmark.measure("headlessCms.graphql.processRequestBody", async () => {
|
|
71
|
+
try {
|
|
72
|
+
result = await (0, _handlerGraphql.processRequestBody)(body, schema, context);
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
console.error(`Error while processing the body request.`);
|
|
75
|
+
console.error((0, _formatErrorPayload.formatErrorPayload)(ex));
|
|
76
|
+
throw ex;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return reply.code(200).send(result);
|
|
80
|
+
};
|
|
81
|
+
exports.handleRequest = handleRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","getLastModifiedTime","getModelLastChange","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody"],"sources":["handleRequest.ts"],"sourcesContent":["import { ApiEndpoint, CmsContext } from \"~/types\";\nimport { checkEndpointAccess } from \"./checkEndpointAccess\";\nimport { createRequestBody } from \"./createRequestBody\";\nimport { formatErrorPayload } from \"./formatErrorPayload\";\nimport { getSchema } from \"./getSchema\";\nimport { Reply, Request } from \"@webiny/handler/types\";\nimport { processRequestBody } from \"@webiny/handler-graphql\";\nimport { ExecutionResult } from \"graphql\";\n\nexport interface HandleRequestParams {\n context: CmsContext;\n request: Request;\n reply: Reply;\n}\n\nexport interface HandleRequest {\n (params: HandleRequestParams): Promise<Reply>;\n}\n\nexport const handleRequest: HandleRequest = async params => {\n const { context, request, reply } = params;\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getLastModifiedTime = async () => {\n return context.cms.getModelLastChange();\n };\n\n const schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\n getLastModifiedTime,\n getLocale,\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n const body = await context.benchmark.measure(\n \"headlessCms.graphql.createRequestBody\",\n async () => {\n try {\n return createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n /**\n * We need to store the processRequestBody result in a variable and output it after the measurement.\n * Otherwise, the measurement will not be shown in the output.\n */\n let result: ExecutionResult[] | ExecutionResult | null = null;\n\n await context.benchmark.measure(\"headlessCms.graphql.processRequestBody\", async () => {\n try {\n result = await processRequestBody(body, schema, context);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n return reply.code(200).send(result);\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AAEA;AAaO,MAAMA,aAA4B,GAAG,MAAMC,MAAM,IAAI;EACxD,MAAM;IAAEC,OAAO;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAC1C,IAAI;IACA,MAAM,IAAAI,wCAAmB,EAACH,OAAO,CAAC;EACtC,CAAC,CAAC,OAAOI,EAAE,EAAE;IACT,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;MACxBC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAEL,EAAE,CAACK,OAAO,IAAI,iBAAiB;QACxCJ,IAAI,EAAED,EAAE,CAACC,IAAI,IAAI,yBAAyB;QAC1CE,IAAI,EAAEH,EAAE,CAACG,IAAI,IAAI,IAAI;QACrBG,KAAK,EAAE;MACX;IACJ,CAAC,CAAC;EACN;EAEA,MAAMC,SAAS,GAAG,MAAM;IACpB,OAAOX,OAAO,CAACY,OAAO,CAACC,gBAAgB,EAAE;EAC7C,CAAC;EAED,MAAMC,SAAS,GAAG,MAAM;IACpB,OAAOd,OAAO,CAACe,GAAG,CAACD,SAAS,EAAE;EAClC,CAAC;EAED,MAAME,mBAAmB,GAAG,YAAY;IACpC,OAAOhB,OAAO,CAACe,GAAG,CAACE,kBAAkB,EAAE;EAC3C,CAAC;EAED,MAAMC,MAAM,GAAG,MAAMlB,OAAO,CAACmB,SAAS,CAACC,OAAO,CAAC,+BAA+B,EAAE,YAAY;IACxF,IAAI;MACA,OAAO,MAAM,IAAAC,oBAAS,EAAC;QACnBrB,OAAO;QACPW,SAAS;QACTK,mBAAmB;QACnBF,SAAS;QACTQ,IAAI,EAAEtB,OAAO,CAACe,GAAG,CAACO;MACtB,CAAC,CAAC;IACN,CAAC,CAAC,OAAOlB,EAAE,EAAE;MACTmB,OAAO,CAACf,KAAK,CAAE,oCAAmC,CAAC;MACnDe,OAAO,CAACf,KAAK,CAAC,IAAAgB,sCAAkB,EAACpB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;EAEF,MAAMqB,IAAI,GAAG,MAAMzB,OAAO,CAACmB,SAAS,CAACC,OAAO,CACxC,uCAAuC,EACvC,YAAY;IACR,IAAI;MACA,OAAO,IAAAM,oCAAiB,EAACzB,OAAO,CAACwB,IAAI,CAAC;IAC1C,CAAC,CAAC,OAAOrB,EAAE,EAAE;MACTmB,OAAO,CAACf,KAAK,CAAE,wCAAuC,CAAC;MACvDe,OAAO,CAACf,KAAK,CAAC,IAAAgB,sCAAkB,EAACpB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CACJ;;EAED;AACJ;AACA;AACA;EACI,IAAIuB,MAAkD,GAAG,IAAI;EAE7D,MAAM3B,OAAO,CAACmB,SAAS,CAACC,OAAO,CAAC,wCAAwC,EAAE,YAAY;IAClF,IAAI;MACAO,MAAM,GAAG,MAAM,IAAAC,kCAAkB,EAACH,IAAI,EAAEP,MAAM,EAAElB,OAAO,CAAC;IAC5D,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTmB,OAAO,CAACf,KAAK,CAAE,0CAAyC,CAAC;MACzDe,OAAO,CAACf,KAAK,CAAC,IAAAgB,sCAAkB,EAACpB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;EAEF,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAACqB,MAAM,CAAC;AACvC,CAAC;AAAC"}
|
package/graphql/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
|
|
2
1
|
import { GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory";
|
|
3
|
-
import { CmsContext } from "../types";
|
|
4
2
|
export declare type CreateGraphQLParams = GraphQLHandlerFactoryParams;
|
|
5
|
-
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/
|
|
3
|
+
export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("../types").CmsContext> | import("@webiny/api").ContextPlugin<import("../types").CmsContext> | import("@webiny/plugins/types").PluginCollection)[];
|
package/graphql/index.js
CHANGED
|
@@ -6,45 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createGraphQL = void 0;
|
|
7
7
|
var _system = require("./system");
|
|
8
8
|
var _graphQLHandlerFactory = require("./graphQLHandlerFactory");
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
name: "cms.graphql.schema.base",
|
|
12
|
-
type: "graphql-schema",
|
|
13
|
-
schema: {
|
|
14
|
-
typeDefs: /* GraphQL */`
|
|
15
|
-
type CmsError {
|
|
16
|
-
code: String
|
|
17
|
-
message: String
|
|
18
|
-
data: JSON
|
|
19
|
-
stack: String
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type CmsCursors {
|
|
23
|
-
next: String
|
|
24
|
-
previous: String
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type CmsListMeta {
|
|
28
|
-
cursor: String
|
|
29
|
-
hasMoreItems: Boolean
|
|
30
|
-
totalCount: Int
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type CmsDeleteResponse {
|
|
34
|
-
data: Boolean
|
|
35
|
-
error: CmsError
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type CmsBooleanResponse {
|
|
39
|
-
data: Boolean
|
|
40
|
-
error: CmsError
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
resolvers: {}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
};
|
|
9
|
+
var _baseSchema = require("./schema/baseSchema");
|
|
47
10
|
const createGraphQL = params => {
|
|
48
|
-
return [createBaseSchema(), (0, _system.createSystemSchemaPlugin)(), (0, _graphQLHandlerFactory.graphQLHandlerFactory)(params)];
|
|
11
|
+
return [...(0, _baseSchema.createBaseSchema)(), (0, _system.createSystemSchemaPlugin)(), (0, _graphQLHandlerFactory.graphQLHandlerFactory)(params)];
|
|
49
12
|
};
|
|
50
13
|
exports.createGraphQL = createGraphQL;
|
package/graphql/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createGraphQL","params","createBaseSchema","createSystemSchemaPlugin","graphQLHandlerFactory"],"sources":["index.ts"],"sourcesContent":["import { createSystemSchemaPlugin } from \"./system\";\nimport { graphQLHandlerFactory, GraphQLHandlerFactoryParams } from \"./graphQLHandlerFactory\";\nimport { createBaseSchema } from \"~/graphql/schema/baseSchema\";\n\nexport type CreateGraphQLParams = GraphQLHandlerFactoryParams;\nexport const createGraphQL = (params: CreateGraphQLParams) => {\n return [...createBaseSchema(), createSystemSchemaPlugin(), graphQLHandlerFactory(params)];\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAGO,MAAMA,aAAa,GAAIC,MAA2B,IAAK;EAC1D,OAAO,CAAC,GAAG,IAAAC,4BAAgB,GAAE,EAAE,IAAAC,gCAAwB,GAAE,EAAE,IAAAC,4CAAqB,EAACH,MAAM,CAAC,CAAC;AAC7F,CAAC;AAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { CmsContext } from "../../types";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { CmsGraphQLSchemaPlugin } from "../../plugins";
|
|
3
|
+
interface Params {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
}
|
|
6
|
+
export declare const createBaseContentSchema: ({ context }: Params) => CmsGraphQLSchemaPlugin;
|
|
7
|
+
export {};
|
|
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createBaseContentSchema = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _builtInTypes = require("@webiny/handler-graphql/builtInTypes");
|
|
10
|
-
var
|
|
11
|
-
const createBaseContentSchema =
|
|
10
|
+
var _plugins = require("../../plugins");
|
|
11
|
+
const createBaseContentSchema = ({
|
|
12
|
+
context
|
|
13
|
+
}) => {
|
|
12
14
|
const scalars = context.plugins.byType("graphql-scalar").map(item => item.scalar);
|
|
13
|
-
|
|
15
|
+
const plugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
14
16
|
typeDefs: /* GraphQL */`
|
|
15
17
|
${scalars.map(scalar => `scalar ${scalar.name}`).join(" ")}
|
|
16
18
|
scalar JSON
|
|
@@ -29,13 +31,7 @@ const createBaseContentSchema = context => {
|
|
|
29
31
|
_empty: String
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
type
|
|
33
|
-
id: String
|
|
34
|
-
displayName: String
|
|
35
|
-
type: String
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type CmsOwnedBy {
|
|
34
|
+
type CmsIdentity {
|
|
39
35
|
id: String
|
|
40
36
|
displayName: String
|
|
41
37
|
type: String
|
|
@@ -52,7 +48,7 @@ const createBaseContentSchema = context => {
|
|
|
52
48
|
}, {})), {}, {
|
|
53
49
|
JSON: _builtInTypes.JsonScalar,
|
|
54
50
|
Long: _builtInTypes.LongScalar,
|
|
55
|
-
RefInput: _builtInTypes.
|
|
51
|
+
RefInput: _builtInTypes.RefInputScalar,
|
|
56
52
|
Number: _builtInTypes.NumberScalar,
|
|
57
53
|
Any: _builtInTypes.AnyScalar,
|
|
58
54
|
DateTime: _builtInTypes.DateTimeScalar,
|
|
@@ -64,5 +60,7 @@ const createBaseContentSchema = context => {
|
|
|
64
60
|
}
|
|
65
61
|
})
|
|
66
62
|
});
|
|
63
|
+
plugin.name = `headless-cms.graphql.schema.baseContentSchema`;
|
|
64
|
+
return plugin;
|
|
67
65
|
};
|
|
68
66
|
exports.createBaseContentSchema = createBaseContentSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","
|
|
1
|
+
{"version":3,"names":["createBaseContentSchema","context","scalars","plugins","byType","map","item","scalar","plugin","CmsGraphQLSchemaPlugin","typeDefs","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","DateTimeZ","DateTimeZScalar","Date","DateScalar","Time","TimeScalar","Mutation","_empty"],"sources":["baseContentSchema.ts"],"sourcesContent":["import { GraphQLScalarPlugin } from \"@webiny/handler-graphql/types\";\nimport { CmsContext } from \"~/types\";\nimport {\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar,\n LongScalar,\n JsonScalar,\n DateTimeZScalar\n} from \"@webiny/handler-graphql/builtInTypes\";\nimport { GraphQLScalarType } from \"graphql\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createBaseContentSchema = ({ context }: Params): CmsGraphQLSchemaPlugin => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n const plugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Query\n\n type Mutation {\n _empty: String\n }\n\n type CmsIdentity {\n id: String\n displayName: String\n type: String\n }\n\n enum CmsEntryStatusType {\n latest\n published\n }\n `,\n resolvers: {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar,\n Mutation: {\n _empty: () => \"_empty\"\n }\n }\n });\n plugin.name = `headless-cms.graphql.schema.baseContentSchema`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;AAEA;AAYA;AAKO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAA6B;EACpF,MAAMC,OAAO,GAAGD,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;EAE7B,MAAMC,MAAM,GAAG,IAAIC,+BAAsB,CAAC;IACtCC,QAAQ,EAAE,aAAe;AACjC,cAAcR,OAAO,CAACG,GAAG,CAACE,MAAM,IAAK,UAASA,MAAM,CAACI,IAAK,EAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,8DACFX,OAAO,CAACY,MAAM,CAAoC,CAACC,GAAG,EAAEC,CAAC,KAAK;MAC7DD,GAAG,CAACC,CAAC,CAACL,IAAI,CAAC,GAAGK,CAAC;MACf,OAAOD,GAAG;IACd,CAAC,EAAE,CAAC,CAAC,CAAC;MACNE,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAEC,4BAAc;MACxBC,MAAM,EAAEC,0BAAY;MACpBC,GAAG,EAAEC,uBAAS;MACdC,QAAQ,EAAEC,4BAAc;MACxBC,SAAS,EAAEC,6BAAe;MAC1BC,IAAI,EAAEC,wBAAU;MAChBC,IAAI,EAAEC,wBAAU;MAChBC,QAAQ,EAAE;QACNC,MAAM,EAAE,MAAM;MAClB;IAAC;EAET,CAAC,CAAC;EACF5B,MAAM,CAACG,IAAI,GAAI,+CAA8C;EAE7D,OAAOH,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBaseSchema = void 0;
|
|
7
|
+
var _plugins = require("../../plugins");
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
const createBaseSchema = () => {
|
|
10
|
+
const cmsPlugin = new _plugins.CmsGraphQLSchemaPlugin({
|
|
11
|
+
typeDefs: /* GraphQL */`
|
|
12
|
+
type CmsError {
|
|
13
|
+
code: String
|
|
14
|
+
message: String
|
|
15
|
+
data: JSON
|
|
16
|
+
stack: String
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type CmsCursors {
|
|
20
|
+
next: String
|
|
21
|
+
previous: String
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type CmsListMeta {
|
|
25
|
+
cursor: String
|
|
26
|
+
hasMoreItems: Boolean
|
|
27
|
+
totalCount: Int
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
input CmsDeleteEntryOptions {
|
|
31
|
+
# force delete an entry that might have some records left behind in the database
|
|
32
|
+
# see CmsDeleteEntryOptions in types.ts
|
|
33
|
+
force: Boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type CmsDeleteResponse {
|
|
37
|
+
data: Boolean
|
|
38
|
+
error: CmsError
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type CmsDeleteMultipleDataResponse {
|
|
42
|
+
id: ID!
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type CmsDeleteMultipleResponse {
|
|
46
|
+
data: [CmsDeleteMultipleDataResponse!]
|
|
47
|
+
error: CmsError
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type CmsBooleanResponse {
|
|
51
|
+
data: Boolean
|
|
52
|
+
error: CmsError
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
resolvers: {}
|
|
56
|
+
});
|
|
57
|
+
cmsPlugin.name = "headless-cms.graphql.schema.base";
|
|
58
|
+
const corePlugin = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
59
|
+
typeDefs: cmsPlugin.schema.typeDefs,
|
|
60
|
+
resolvers: cmsPlugin.schema.resolvers
|
|
61
|
+
});
|
|
62
|
+
corePlugin.name = "headless-cms.graphql.core.schema.base";
|
|
63
|
+
/**
|
|
64
|
+
* Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.
|
|
65
|
+
*/
|
|
66
|
+
return [cmsPlugin, corePlugin];
|
|
67
|
+
};
|
|
68
|
+
exports.createBaseSchema = createBaseSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBaseSchema","cmsPlugin","CmsGraphQLSchemaPlugin","typeDefs","resolvers","name","corePlugin","GraphQLSchemaPlugin","schema"],"sources":["baseSchema.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nexport const createBaseSchema = (): GraphQLSchemaPlugin<CmsContext>[] => {\n const cmsPlugin = new CmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type CmsCursors {\n next: String\n previous: String\n }\n\n type CmsListMeta {\n cursor: String\n hasMoreItems: Boolean\n totalCount: Int\n }\n\n input CmsDeleteEntryOptions {\n # force delete an entry that might have some records left behind in the database\n # see CmsDeleteEntryOptions in types.ts\n force: Boolean\n }\n\n type CmsDeleteResponse {\n data: Boolean\n error: CmsError\n }\n\n type CmsDeleteMultipleDataResponse {\n id: ID!\n }\n\n type CmsDeleteMultipleResponse {\n data: [CmsDeleteMultipleDataResponse!]\n error: CmsError\n }\n\n type CmsBooleanResponse {\n data: Boolean\n error: CmsError\n }\n `,\n resolvers: {}\n });\n cmsPlugin.name = \"headless-cms.graphql.schema.base\";\n const corePlugin = new GraphQLSchemaPlugin<CmsContext>({\n typeDefs: cmsPlugin.schema.typeDefs,\n resolvers: cmsPlugin.schema.resolvers\n });\n corePlugin.name = \"headless-cms.graphql.core.schema.base\";\n /**\n * Due to splitting of CMS and Core schema plugins, we must have both defined for CMS to work.\n */\n return [cmsPlugin, corePlugin];\n};\n"],"mappings":";;;;;;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,MAAyC;EACrE,MAAMC,SAAS,GAAG,IAAIC,+BAAsB,CAAC;IACzCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE,CAAC;EAChB,CAAC,CAAC;EACFH,SAAS,CAACI,IAAI,GAAG,kCAAkC;EACnD,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAa;IACnDJ,QAAQ,EAAEF,SAAS,CAACO,MAAM,CAACL,QAAQ;IACnCC,SAAS,EAAEH,SAAS,CAACO,MAAM,CAACJ;EAChC,CAAC,CAAC;EACFE,UAAU,CAACD,IAAI,GAAG,uCAAuC;EACzD;AACJ;AACA;EACI,OAAO,CAACJ,SAAS,EAAEK,UAAU,CAAC;AAClC,CAAC;AAAC"}
|