@strapi/plugin-graphql 4.15.5 → 4.16.1
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/dist/admin/admin/src/index.d.ts +16 -0
- package/dist/admin/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/index.js +31 -17
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +31 -17
- package/dist/admin/index.mjs.map +1 -1
- package/dist/server/bootstrap.d.ts +5 -0
- package/dist/server/bootstrap.d.ts.map +1 -0
- package/dist/server/config/default-config.d.ts +9 -0
- package/dist/server/config/default-config.d.ts.map +1 -0
- package/dist/server/config/index.d.ts +10 -0
- package/dist/server/config/index.d.ts.map +1 -0
- package/dist/server/format-graphql-error.d.ts +4 -0
- package/dist/server/format-graphql-error.d.ts.map +1 -0
- package/dist/server/index.d.ts +301 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2970 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +2949 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/services/builders/dynamic-zones.d.ts +14 -0
- package/dist/server/services/builders/dynamic-zones.d.ts.map +1 -0
- package/dist/server/services/builders/entity-meta.d.ts +6 -0
- package/dist/server/services/builders/entity-meta.d.ts.map +1 -0
- package/dist/server/services/builders/entity.d.ts +12 -0
- package/dist/server/services/builders/entity.d.ts.map +1 -0
- package/dist/server/services/builders/enums.d.ts +8 -0
- package/dist/server/services/builders/enums.d.ts.map +1 -0
- package/dist/server/services/builders/filters/content-type.d.ts +8 -0
- package/dist/server/services/builders/filters/content-type.d.ts.map +1 -0
- package/dist/server/services/builders/filters/index.d.ts +6 -0
- package/dist/server/services/builders/filters/index.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/and.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/and.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/between.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/between.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/contains.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/contains.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/containsi.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/containsi.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/ends-with.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/ends-with.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/eq.d.ts +11 -0
- package/dist/server/services/builders/filters/operators/eq.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/eqi.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/eqi.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/gt.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/gt.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/gte.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/gte.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/in.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/in.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/index.d.ts +11 -0
- package/dist/server/services/builders/filters/operators/index.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/lt.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/lt.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/lte.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/lte.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/ne.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/ne.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/nei.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/nei.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/not-contains.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/not-contains.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/not-containsi.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/not-containsi.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/not-in.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/not-in.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/not-null.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/not-null.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/not.d.ts +11 -0
- package/dist/server/services/builders/filters/operators/not.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/null.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/null.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/or.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/or.d.ts.map +1 -0
- package/dist/server/services/builders/filters/operators/starts-with.d.ts +8 -0
- package/dist/server/services/builders/filters/operators/starts-with.d.ts.map +1 -0
- package/dist/server/services/builders/generic-morph.d.ts +6 -0
- package/dist/server/services/builders/generic-morph.d.ts.map +1 -0
- package/dist/server/services/builders/index.d.ts +58 -0
- package/dist/server/services/builders/index.d.ts.map +1 -0
- package/dist/server/services/builders/input.d.ts +7 -0
- package/dist/server/services/builders/input.d.ts.map +1 -0
- package/dist/server/services/builders/mutations/collection-type.d.ts +8 -0
- package/dist/server/services/builders/mutations/collection-type.d.ts.map +1 -0
- package/dist/server/services/builders/mutations/index.d.ts +7 -0
- package/dist/server/services/builders/mutations/index.d.ts.map +1 -0
- package/dist/server/services/builders/mutations/single-type.d.ts +8 -0
- package/dist/server/services/builders/mutations/single-type.d.ts.map +1 -0
- package/dist/server/services/builders/queries/collection-type.d.ts +8 -0
- package/dist/server/services/builders/queries/collection-type.d.ts.map +1 -0
- package/dist/server/services/builders/queries/index.d.ts +7 -0
- package/dist/server/services/builders/queries/index.d.ts.map +1 -0
- package/dist/server/services/builders/queries/single-type.d.ts +8 -0
- package/dist/server/services/builders/queries/single-type.d.ts.map +1 -0
- package/dist/server/services/builders/relation-response-collection.d.ts +10 -0
- package/dist/server/services/builders/relation-response-collection.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/association.d.ts +10 -0
- package/dist/server/services/builders/resolvers/association.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/component.d.ts +10 -0
- package/dist/server/services/builders/resolvers/component.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/dynamic-zone.d.ts +10 -0
- package/dist/server/services/builders/resolvers/dynamic-zone.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/index.d.ts +30 -0
- package/dist/server/services/builders/resolvers/index.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/mutation.d.ts +13 -0
- package/dist/server/services/builders/resolvers/mutation.d.ts.map +1 -0
- package/dist/server/services/builders/resolvers/query.d.ts +12 -0
- package/dist/server/services/builders/resolvers/query.d.ts.map +1 -0
- package/dist/server/services/builders/response-collection.d.ts +12 -0
- package/dist/server/services/builders/response-collection.d.ts.map +1 -0
- package/dist/server/services/builders/response.d.ts +10 -0
- package/dist/server/services/builders/response.d.ts.map +1 -0
- package/dist/server/services/builders/type.d.ts +19 -0
- package/dist/server/services/builders/type.d.ts.map +1 -0
- package/dist/server/services/builders/utils.d.ts +52 -0
- package/dist/server/services/builders/utils.d.ts.map +1 -0
- package/dist/server/services/constants.d.ts +128 -0
- package/dist/server/services/constants.d.ts.map +1 -0
- package/dist/server/services/content-api/index.d.ts +8 -0
- package/dist/server/services/content-api/index.d.ts.map +1 -0
- package/dist/server/services/content-api/policy.d.ts +7 -0
- package/dist/server/services/content-api/policy.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/collection-type.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/collection-type.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/component.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/component.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/content-type/dynamic-zones.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/content-type/dynamic-zones.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/content-type/enums.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/content-type/enums.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/content-type/filters.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/content-type/filters.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/content-type/index.d.ts +24 -0
- package/dist/server/services/content-api/register-functions/content-type/index.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/content-type/inputs.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/content-type/inputs.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/index.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/index.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/internals.d.ts +4 -0
- package/dist/server/services/content-api/register-functions/internals.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/polymorphic.d.ts +5 -0
- package/dist/server/services/content-api/register-functions/polymorphic.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/scalars.d.ts +4 -0
- package/dist/server/services/content-api/register-functions/scalars.d.ts.map +1 -0
- package/dist/server/services/content-api/register-functions/single-type.d.ts +9 -0
- package/dist/server/services/content-api/register-functions/single-type.d.ts.map +1 -0
- package/dist/server/services/content-api/wrap-resolvers.d.ts +18 -0
- package/dist/server/services/content-api/wrap-resolvers.d.ts.map +1 -0
- package/dist/server/services/extension/extension.d.ts +63 -0
- package/dist/server/services/extension/extension.d.ts.map +1 -0
- package/dist/server/services/extension/index.d.ts +3 -0
- package/dist/server/services/extension/index.d.ts.map +1 -0
- package/dist/server/services/extension/shadow-crud-manager.d.ts +40 -0
- package/dist/server/services/extension/shadow-crud-manager.d.ts.map +1 -0
- package/dist/server/services/format/index.d.ts +20 -0
- package/dist/server/services/format/index.d.ts.map +1 -0
- package/dist/server/services/format/return-types.d.ts +22 -0
- package/dist/server/services/format/return-types.d.ts.map +1 -0
- package/dist/server/services/index.d.ts +287 -0
- package/dist/server/services/index.d.ts.map +1 -0
- package/dist/server/services/internals/args/index.d.ts +8 -0
- package/dist/server/services/internals/args/index.d.ts.map +1 -0
- package/dist/server/services/internals/args/pagination.d.ts +3 -0
- package/dist/server/services/internals/args/pagination.d.ts.map +1 -0
- package/dist/server/services/internals/args/publication-state.d.ts +4 -0
- package/dist/server/services/internals/args/publication-state.d.ts.map +1 -0
- package/dist/server/services/internals/args/sort.d.ts +3 -0
- package/dist/server/services/internals/args/sort.d.ts.map +1 -0
- package/dist/server/services/internals/helpers/get-enabled-scalars.d.ts +4 -0
- package/dist/server/services/internals/helpers/get-enabled-scalars.d.ts.map +1 -0
- package/dist/server/services/internals/helpers/index.d.ts +6 -0
- package/dist/server/services/internals/helpers/index.d.ts.map +1 -0
- package/dist/server/services/internals/index.d.ts +46 -0
- package/dist/server/services/internals/index.d.ts.map +1 -0
- package/dist/server/services/internals/scalars/date.d.ts +3 -0
- package/dist/server/services/internals/scalars/date.d.ts.map +1 -0
- package/dist/server/services/internals/scalars/index.d.ts +10 -0
- package/dist/server/services/internals/scalars/index.d.ts.map +1 -0
- package/dist/server/services/internals/scalars/time.d.ts +8 -0
- package/dist/server/services/internals/scalars/time.d.ts.map +1 -0
- package/dist/server/services/internals/types/error.d.ts +8 -0
- package/dist/server/services/internals/types/error.d.ts.map +1 -0
- package/dist/server/services/internals/types/filters.d.ts +6 -0
- package/dist/server/services/internals/types/filters.d.ts.map +1 -0
- package/dist/server/services/internals/types/index.d.ts +28 -0
- package/dist/server/services/internals/types/index.d.ts.map +1 -0
- package/dist/server/services/internals/types/pagination.d.ts +10 -0
- package/dist/server/services/internals/types/pagination.d.ts.map +1 -0
- package/dist/server/services/internals/types/publication-state.d.ts +10 -0
- package/dist/server/services/internals/types/publication-state.d.ts.map +1 -0
- package/dist/server/services/internals/types/response-collection-meta.d.ts +11 -0
- package/dist/server/services/internals/types/response-collection-meta.d.ts.map +1 -0
- package/dist/server/services/type-registry.d.ts +15 -0
- package/dist/server/services/type-registry.d.ts.map +1 -0
- package/dist/server/services/types.d.ts +7 -0
- package/dist/server/services/types.d.ts.map +1 -0
- package/dist/server/services/utils/attributes.d.ts +14 -0
- package/dist/server/services/utils/attributes.d.ts.map +1 -0
- package/dist/server/services/utils/index.d.ts +81 -0
- package/dist/server/services/utils/index.d.ts.map +1 -0
- package/dist/server/services/utils/mappers/entity-to-response-entity.d.ts +33 -0
- package/dist/server/services/utils/mappers/entity-to-response-entity.d.ts.map +1 -0
- package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.d.ts +13 -0
- package/dist/server/services/utils/mappers/graphql-filters-to-strapi-query.d.ts.map +1 -0
- package/dist/server/services/utils/mappers/graphql-scalar-to-operators.d.ts +6 -0
- package/dist/server/services/utils/mappers/graphql-scalar-to-operators.d.ts.map +1 -0
- package/dist/server/services/utils/mappers/index.d.ts +36 -0
- package/dist/server/services/utils/mappers/index.d.ts.map +1 -0
- package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.d.ts +9 -0
- package/dist/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.d.ts.map +1 -0
- package/dist/server/services/utils/naming.d.ts +37 -0
- package/dist/server/services/utils/naming.d.ts.map +1 -0
- package/package.json +28 -16
- package/strapi-server.js +1 -11
- package/.eslintignore +0 -1
- package/.eslintrc +0 -14
- package/admin/src/index.js +0 -38
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/dk.json +0 -5
- package/admin/src/translations/en.json +0 -5
- package/admin/src/translations/es.json +0 -5
- package/admin/src/translations/fr.json +0 -5
- package/admin/src/translations/pl.json +0 -5
- package/admin/src/translations/ru.json +0 -5
- package/admin/src/translations/sv.json +0 -5
- package/admin/src/translations/tr.json +0 -5
- package/admin/src/translations/zh-Hans.json +0 -5
- package/admin/src/translations/zh.json +0 -5
- package/packup.config.ts +0 -42
- package/server/bootstrap.js +0 -134
- package/server/config/default-config.js +0 -13
- package/server/config/index.js +0 -7
- package/server/format-graphql-error.js +0 -45
- package/server/services/builders/dynamic-zones.js +0 -97
- package/server/services/builders/entity-meta.js +0 -7
- package/server/services/builders/entity.js +0 -43
- package/server/services/builders/enums.js +0 -26
- package/server/services/builders/filters/content-type.js +0 -111
- package/server/services/builders/filters/index.js +0 -7
- package/server/services/builders/filters/operators/and.js +0 -15
- package/server/services/builders/filters/operators/between.js +0 -15
- package/server/services/builders/filters/operators/contains.js +0 -13
- package/server/services/builders/filters/operators/containsi.js +0 -13
- package/server/services/builders/filters/operators/ends-with.js +0 -13
- package/server/services/builders/filters/operators/eq.js +0 -23
- package/server/services/builders/filters/operators/eqi.js +0 -13
- package/server/services/builders/filters/operators/gt.js +0 -13
- package/server/services/builders/filters/operators/gte.js +0 -13
- package/server/services/builders/filters/operators/in.js +0 -15
- package/server/services/builders/filters/operators/index.js +0 -40
- package/server/services/builders/filters/operators/lt.js +0 -13
- package/server/services/builders/filters/operators/lte.js +0 -13
- package/server/services/builders/filters/operators/ne.js +0 -13
- package/server/services/builders/filters/operators/nei.js +0 -13
- package/server/services/builders/filters/operators/not-contains.js +0 -13
- package/server/services/builders/filters/operators/not-containsi.js +0 -13
- package/server/services/builders/filters/operators/not-in.js +0 -15
- package/server/services/builders/filters/operators/not-null.js +0 -13
- package/server/services/builders/filters/operators/not.js +0 -19
- package/server/services/builders/filters/operators/null.js +0 -13
- package/server/services/builders/filters/operators/or.js +0 -15
- package/server/services/builders/filters/operators/starts-with.js +0 -13
- package/server/services/builders/generic-morph.js +0 -41
- package/server/services/builders/index.js +0 -92
- package/server/services/builders/input.js +0 -121
- package/server/services/builders/mutations/collection-type.js +0 -191
- package/server/services/builders/mutations/index.js +0 -9
- package/server/services/builders/mutations/single-type.js +0 -164
- package/server/services/builders/queries/collection-type.js +0 -122
- package/server/services/builders/queries/index.js +0 -9
- package/server/services/builders/queries/single-type.js +0 -71
- package/server/services/builders/relation-response-collection.js +0 -32
- package/server/services/builders/resolvers/association.js +0 -92
- package/server/services/builders/resolvers/component.js +0 -25
- package/server/services/builders/resolvers/dynamic-zone.js +0 -9
- package/server/services/builders/resolvers/index.js +0 -18
- package/server/services/builders/resolvers/mutation.js +0 -38
- package/server/services/builders/resolvers/query.js +0 -34
- package/server/services/builders/response-collection.js +0 -40
- package/server/services/builders/response.js +0 -32
- package/server/services/builders/type.js +0 -363
- package/server/services/builders/utils.js +0 -134
- package/server/services/constants.js +0 -153
- package/server/services/content-api/index.js +0 -188
- package/server/services/content-api/policy.js +0 -60
- package/server/services/content-api/register-functions/collection-type.js +0 -72
- package/server/services/content-api/register-functions/component.js +0 -15
- package/server/services/content-api/register-functions/content-type/dynamic-zones.js +0 -36
- package/server/services/content-api/register-functions/content-type/enums.js +0 -33
- package/server/services/content-api/register-functions/content-type/filters.js +0 -15
- package/server/services/content-api/register-functions/content-type/index.js +0 -13
- package/server/services/content-api/register-functions/content-type/inputs.js +0 -21
- package/server/services/content-api/register-functions/index.js +0 -22
- package/server/services/content-api/register-functions/internals.js +0 -13
- package/server/services/content-api/register-functions/polymorphic.js +0 -69
- package/server/services/content-api/register-functions/scalars.js +0 -14
- package/server/services/content-api/register-functions/single-type.js +0 -72
- package/server/services/content-api/wrap-resolvers.js +0 -148
- package/server/services/extension/extension.js +0 -94
- package/server/services/extension/index.js +0 -5
- package/server/services/extension/shadow-crud-manager.js +0 -161
- package/server/services/format/index.js +0 -7
- package/server/services/format/return-types.js +0 -27
- package/server/services/index.js +0 -21
- package/server/services/internals/args/index.js +0 -11
- package/server/services/internals/args/pagination.js +0 -19
- package/server/services/internals/args/publication-state.js +0 -12
- package/server/services/internals/args/sort.js +0 -10
- package/server/services/internals/helpers/get-enabled-scalars.js +0 -17
- package/server/services/internals/helpers/index.js +0 -7
- package/server/services/internals/index.js +0 -13
- package/server/services/internals/scalars/date.js +0 -22
- package/server/services/internals/scalars/index.js +0 -17
- package/server/services/internals/scalars/time.js +0 -36
- package/server/services/internals/types/error.js +0 -34
- package/server/services/internals/types/filters.js +0 -39
- package/server/services/internals/types/index.js +0 -29
- package/server/services/internals/types/pagination.js +0 -24
- package/server/services/internals/types/publication-state.js +0 -24
- package/server/services/internals/types/response-collection-meta.js +0 -46
- package/server/services/type-registry.js +0 -104
- package/server/services/utils/attributes.js +0 -78
- package/server/services/utils/index.js +0 -11
- package/server/services/utils/mappers/entity-to-response-entity.js +0 -12
- package/server/services/utils/mappers/graphql-filters-to-strapi-query.js +0 -119
- package/server/services/utils/mappers/graphql-scalar-to-operators.js +0 -17
- package/server/services/utils/mappers/index.js +0 -13
- package/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.js +0 -25
- package/server/services/utils/naming.js +0 -287
|
@@ -0,0 +1,2970 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fp = require("lodash/fp");
|
|
3
|
+
const apolloServerKoa = require("apollo-server-koa");
|
|
4
|
+
const apolloServerCore = require("apollo-server-core");
|
|
5
|
+
const depthLimit = require("graphql-depth-limit");
|
|
6
|
+
const graphqlUploadKoa = require("graphql-upload/graphqlUploadKoa.js");
|
|
7
|
+
const utils$2 = require("@strapi/utils");
|
|
8
|
+
const graphql = require("graphql");
|
|
9
|
+
const utils$3 = require("@graphql-tools/utils");
|
|
10
|
+
const nexus = require("nexus");
|
|
11
|
+
const pluralize = require("pluralize");
|
|
12
|
+
const graphqlScalars = require("graphql-scalars");
|
|
13
|
+
const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
|
|
14
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule)
|
|
17
|
+
return e;
|
|
18
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
19
|
+
if (e) {
|
|
20
|
+
for (const k in e) {
|
|
21
|
+
if (k !== "default") {
|
|
22
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: () => e[k]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
n.default = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
const depthLimit__default = /* @__PURE__ */ _interopDefault(depthLimit);
|
|
34
|
+
const graphqlUploadKoa__default = /* @__PURE__ */ _interopDefault(graphqlUploadKoa);
|
|
35
|
+
const nexus__namespace = /* @__PURE__ */ _interopNamespace(nexus);
|
|
36
|
+
const GraphQLUpload__default = /* @__PURE__ */ _interopDefault(GraphQLUpload);
|
|
37
|
+
const defaultConfig = {
|
|
38
|
+
shadowCRUD: true,
|
|
39
|
+
endpoint: "/graphql",
|
|
40
|
+
subscriptions: false,
|
|
41
|
+
maxLimit: -1,
|
|
42
|
+
apolloServer: {}
|
|
43
|
+
};
|
|
44
|
+
const config = {
|
|
45
|
+
default: defaultConfig
|
|
46
|
+
};
|
|
47
|
+
const { HttpError, ForbiddenError: ForbiddenError$1, UnauthorizedError, ApplicationError: ApplicationError$5, ValidationError: ValidationError$3 } = utils$2.errors;
|
|
48
|
+
const formatToCode = (name) => `STRAPI_${fp.toUpper(fp.snakeCase(name))}`;
|
|
49
|
+
const formatErrorToExtension = (error2) => ({
|
|
50
|
+
error: fp.pick(["name", "message", "details"])(error2)
|
|
51
|
+
});
|
|
52
|
+
function formatGraphqlError(error2) {
|
|
53
|
+
const { originalError } = error2;
|
|
54
|
+
if (fp.isEmpty(originalError)) {
|
|
55
|
+
return error2;
|
|
56
|
+
}
|
|
57
|
+
if (originalError instanceof ForbiddenError$1 || originalError instanceof UnauthorizedError) {
|
|
58
|
+
return new apolloServerKoa.ForbiddenError(originalError.message, formatErrorToExtension(originalError));
|
|
59
|
+
}
|
|
60
|
+
if (originalError instanceof ValidationError$3) {
|
|
61
|
+
return new apolloServerKoa.UserInputError(originalError.message, formatErrorToExtension(originalError));
|
|
62
|
+
}
|
|
63
|
+
if (originalError instanceof ApplicationError$5 || originalError instanceof HttpError) {
|
|
64
|
+
const name = formatToCode(originalError.name);
|
|
65
|
+
return new apolloServerKoa.ApolloError(originalError.message, name, formatErrorToExtension(originalError));
|
|
66
|
+
}
|
|
67
|
+
if (originalError instanceof apolloServerKoa.ApolloError || originalError instanceof graphql.GraphQLError) {
|
|
68
|
+
return error2;
|
|
69
|
+
}
|
|
70
|
+
strapi.log.error(originalError);
|
|
71
|
+
return new apolloServerKoa.ApolloError("Internal Server Error", "INTERNAL_SERVER_ERROR");
|
|
72
|
+
}
|
|
73
|
+
const merge = fp.mergeWith((a, b) => {
|
|
74
|
+
if (fp.isArray(a) && fp.isArray(b)) {
|
|
75
|
+
return a.concat(b);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const useUploadMiddleware = (strapi2, path) => {
|
|
79
|
+
const uploadMiddleware = graphqlUploadKoa__default.default();
|
|
80
|
+
strapi2.server.app.use((ctx, next) => {
|
|
81
|
+
if (ctx.path === path) {
|
|
82
|
+
return uploadMiddleware(ctx, next);
|
|
83
|
+
}
|
|
84
|
+
return next();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
async function bootstrap({ strapi: strapi2 }) {
|
|
88
|
+
const schema = strapi2.plugin("graphql").service("content-api").buildSchema();
|
|
89
|
+
if (fp.isEmpty(schema)) {
|
|
90
|
+
strapi2.log.warn("The GraphQL schema has not been generated because it is empty");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { config: config2 } = strapi2.plugin("graphql");
|
|
94
|
+
const path = config2("endpoint");
|
|
95
|
+
const defaultServerConfig = {
|
|
96
|
+
// Schema
|
|
97
|
+
schema,
|
|
98
|
+
// Initialize loaders for this request.
|
|
99
|
+
context: ({ ctx }) => ({
|
|
100
|
+
state: ctx.state,
|
|
101
|
+
koaContext: ctx
|
|
102
|
+
}),
|
|
103
|
+
// Validation
|
|
104
|
+
validationRules: [depthLimit__default.default(config2("depthLimit"))],
|
|
105
|
+
// Errors
|
|
106
|
+
formatError: formatGraphqlError,
|
|
107
|
+
// Misc
|
|
108
|
+
cors: false,
|
|
109
|
+
uploads: false,
|
|
110
|
+
bodyParserConfig: true,
|
|
111
|
+
plugins: [
|
|
112
|
+
process.env.NODE_ENV === "production" && !config2("playgroundAlways") ? apolloServerCore.ApolloServerPluginLandingPageDisabled() : apolloServerCore.ApolloServerPluginLandingPageGraphQLPlayground()
|
|
113
|
+
],
|
|
114
|
+
cache: "bounded"
|
|
115
|
+
};
|
|
116
|
+
const serverConfig = merge(defaultServerConfig, config2("apolloServer"));
|
|
117
|
+
const server = new apolloServerKoa.ApolloServer(serverConfig);
|
|
118
|
+
useUploadMiddleware(strapi2, path);
|
|
119
|
+
try {
|
|
120
|
+
await server.start();
|
|
121
|
+
} catch (error2) {
|
|
122
|
+
if (error2 instanceof Error) {
|
|
123
|
+
strapi2.log.error("Failed to start the Apollo server", error2.message);
|
|
124
|
+
}
|
|
125
|
+
throw error2;
|
|
126
|
+
}
|
|
127
|
+
strapi2.server.routes([
|
|
128
|
+
{
|
|
129
|
+
method: "ALL",
|
|
130
|
+
path,
|
|
131
|
+
handler: [
|
|
132
|
+
(ctx, next) => {
|
|
133
|
+
ctx.state.route = {
|
|
134
|
+
info: {
|
|
135
|
+
// Indicate it's a content API route
|
|
136
|
+
type: "content-api"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
if (ctx.request.method === "GET")
|
|
140
|
+
return next();
|
|
141
|
+
return strapi2.auth.authenticate(ctx, next);
|
|
142
|
+
},
|
|
143
|
+
// Apollo Server
|
|
144
|
+
server.getMiddleware({
|
|
145
|
+
path,
|
|
146
|
+
cors: serverConfig.cors,
|
|
147
|
+
bodyParserConfig: serverConfig.bodyParserConfig
|
|
148
|
+
})
|
|
149
|
+
],
|
|
150
|
+
config: {
|
|
151
|
+
auth: false
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]);
|
|
155
|
+
strapi2.plugin("graphql").destroy = async () => {
|
|
156
|
+
await server.stop();
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const { PolicyError } = utils$2.errors;
|
|
160
|
+
const getPoliciesConfig = fp.propOr([], "policies");
|
|
161
|
+
const createPoliciesMiddleware = (resolverConfig, { strapi: strapi2 }) => {
|
|
162
|
+
const resolverPolicies = getPoliciesConfig(resolverConfig);
|
|
163
|
+
const policies = utils$2.policy.resolve(resolverPolicies, {});
|
|
164
|
+
return async (resolve, parent, args2, context, info) => {
|
|
165
|
+
const policyContext = createGraphQLPolicyContext(parent, args2, context, info);
|
|
166
|
+
for (const { handler, config: config2 } of policies) {
|
|
167
|
+
const result = await handler(policyContext, config2, { strapi: strapi2 });
|
|
168
|
+
if (![true, void 0].includes(result)) {
|
|
169
|
+
throw new PolicyError();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return resolve(parent, args2, context, info);
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const createGraphQLPolicyContext = (parent, args2, context, info) => {
|
|
176
|
+
const policyContext = {
|
|
177
|
+
get parent() {
|
|
178
|
+
return parent;
|
|
179
|
+
},
|
|
180
|
+
get args() {
|
|
181
|
+
return args2;
|
|
182
|
+
},
|
|
183
|
+
get context() {
|
|
184
|
+
return context;
|
|
185
|
+
},
|
|
186
|
+
get info() {
|
|
187
|
+
return info;
|
|
188
|
+
},
|
|
189
|
+
get state() {
|
|
190
|
+
return this.context.state;
|
|
191
|
+
},
|
|
192
|
+
get http() {
|
|
193
|
+
return this.context.koaContext;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
return utils$2.policy.createPolicyContext("graphql", policyContext);
|
|
197
|
+
};
|
|
198
|
+
const { ForbiddenError } = utils$2.errors;
|
|
199
|
+
const introspectionQueries = [
|
|
200
|
+
"__Schema",
|
|
201
|
+
"__Type",
|
|
202
|
+
"__Field",
|
|
203
|
+
"__InputValue",
|
|
204
|
+
"__EnumValue",
|
|
205
|
+
"__Directive"
|
|
206
|
+
];
|
|
207
|
+
const parseMiddlewares = (resolverConfig, strapi2) => {
|
|
208
|
+
const resolverMiddlewares = fp.getOr([], "middlewares", resolverConfig);
|
|
209
|
+
return resolverMiddlewares.map(
|
|
210
|
+
(middleware) => {
|
|
211
|
+
if (fp.isFunction(middleware)) {
|
|
212
|
+
return middleware;
|
|
213
|
+
}
|
|
214
|
+
if (typeof middleware === "string") {
|
|
215
|
+
return strapi2.middleware(middleware);
|
|
216
|
+
}
|
|
217
|
+
if (typeof middleware === "object") {
|
|
218
|
+
const { name, options = {} } = middleware;
|
|
219
|
+
return strapi2.middleware(name)(options, { strapi: strapi2 });
|
|
220
|
+
}
|
|
221
|
+
throw new Error(
|
|
222
|
+
`Invalid middleware type, expected (function,string,object), received ${typeof middleware}`
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
const wrapResolvers = ({
|
|
228
|
+
schema,
|
|
229
|
+
strapi: strapi2,
|
|
230
|
+
extension = {}
|
|
231
|
+
}) => {
|
|
232
|
+
const { resolversConfig = {} } = extension;
|
|
233
|
+
const isValidFieldName = (field) => !field.startsWith("__");
|
|
234
|
+
const typeMap = schema.getTypeMap();
|
|
235
|
+
Object.entries(typeMap).forEach(([type, definition]) => {
|
|
236
|
+
const isGraphQLObjectType = definition instanceof graphql.GraphQLObjectType;
|
|
237
|
+
const isIgnoredType = introspectionQueries.includes(type);
|
|
238
|
+
if (!isGraphQLObjectType || isIgnoredType) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const fields = definition.getFields();
|
|
242
|
+
const fieldsToProcess = Object.entries(fields).filter(([field]) => isValidFieldName(field));
|
|
243
|
+
for (const [fieldName, fieldDefinition] of fieldsToProcess) {
|
|
244
|
+
const defaultResolver = fp.get(fieldName);
|
|
245
|
+
const path = `${type}.${fieldName}`;
|
|
246
|
+
const resolverConfig = fp.getOr({}, path, resolversConfig);
|
|
247
|
+
const { resolve: baseResolver = defaultResolver } = fieldDefinition;
|
|
248
|
+
const middlewares = parseMiddlewares(resolverConfig, strapi2);
|
|
249
|
+
const policyMiddleware = createPoliciesMiddleware(resolverConfig, { strapi: strapi2 });
|
|
250
|
+
middlewares.push(policyMiddleware);
|
|
251
|
+
const boundMiddlewares = middlewares.map((middleware, index2, collection) => {
|
|
252
|
+
return (parents, args2, context, info) => middleware(
|
|
253
|
+
// Make sure the last middleware in the list calls the baseResolver
|
|
254
|
+
index2 >= collection.length - 1 ? baseResolver : boundMiddlewares[index2 + 1],
|
|
255
|
+
parents,
|
|
256
|
+
args2,
|
|
257
|
+
context,
|
|
258
|
+
info
|
|
259
|
+
);
|
|
260
|
+
});
|
|
261
|
+
const authorize = async ({ context }) => {
|
|
262
|
+
const authConfig = fp.get("auth", resolverConfig);
|
|
263
|
+
const authContext = fp.get("state.auth", context);
|
|
264
|
+
const isValidType = ["Mutation", "Query", "Subscription"].includes(type);
|
|
265
|
+
const hasConfig = !fp.isNil(authConfig);
|
|
266
|
+
const isAuthDisabled = authConfig === false;
|
|
267
|
+
if ((isValidType || hasConfig) && !isAuthDisabled) {
|
|
268
|
+
try {
|
|
269
|
+
await strapi2.auth.verify(authContext, authConfig);
|
|
270
|
+
} catch (error2) {
|
|
271
|
+
throw new ForbiddenError();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
fieldDefinition.resolve = async (parent, args2, context, info) => {
|
|
276
|
+
await authorize({ context });
|
|
277
|
+
return fp.first(boundMiddlewares)(parent, args2, context, info);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
return schema;
|
|
282
|
+
};
|
|
283
|
+
const registerCollectionType = (contentType2, {
|
|
284
|
+
registry,
|
|
285
|
+
strapi: strapi2,
|
|
286
|
+
builders: builders2
|
|
287
|
+
}) => {
|
|
288
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
289
|
+
const { naming: naming2 } = getService("utils");
|
|
290
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
291
|
+
const extension = getService("extension");
|
|
292
|
+
const types2 = {
|
|
293
|
+
base: naming2.getTypeName(contentType2),
|
|
294
|
+
entity: naming2.getEntityName(contentType2),
|
|
295
|
+
response: naming2.getEntityResponseName(contentType2),
|
|
296
|
+
responseCollection: naming2.getEntityResponseCollectionName(contentType2),
|
|
297
|
+
relationResponseCollection: naming2.getRelationResponseCollectionName(contentType2),
|
|
298
|
+
queries: naming2.getEntityQueriesTypeName(contentType2),
|
|
299
|
+
mutations: naming2.getEntityMutationsTypeName(contentType2)
|
|
300
|
+
};
|
|
301
|
+
const getConfig = (kind) => ({ kind, contentType: contentType2 });
|
|
302
|
+
registry.register(types2.base, builders2.buildTypeDefinition(contentType2), getConfig(KINDS2.type));
|
|
303
|
+
registry.register(
|
|
304
|
+
types2.entity,
|
|
305
|
+
builders2.buildEntityDefinition(contentType2),
|
|
306
|
+
getConfig(KINDS2.entity)
|
|
307
|
+
);
|
|
308
|
+
registry.register(
|
|
309
|
+
types2.response,
|
|
310
|
+
builders2.buildResponseDefinition(contentType2),
|
|
311
|
+
getConfig(KINDS2.entityResponse)
|
|
312
|
+
);
|
|
313
|
+
registry.register(
|
|
314
|
+
types2.responseCollection,
|
|
315
|
+
builders2.buildResponseCollectionDefinition(contentType2),
|
|
316
|
+
getConfig(KINDS2.entityResponseCollection)
|
|
317
|
+
);
|
|
318
|
+
registry.register(
|
|
319
|
+
types2.relationResponseCollection,
|
|
320
|
+
builders2.buildRelationResponseCollectionDefinition(contentType2),
|
|
321
|
+
getConfig(KINDS2.relationResponseCollection)
|
|
322
|
+
);
|
|
323
|
+
if (extension.shadowCRUD(contentType2.uid).areQueriesEnabled()) {
|
|
324
|
+
registry.register(
|
|
325
|
+
types2.queries,
|
|
326
|
+
builders2.buildCollectionTypeQueries(contentType2),
|
|
327
|
+
getConfig(KINDS2.query)
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
if (extension.shadowCRUD(contentType2.uid).areMutationsEnabled()) {
|
|
331
|
+
registry.register(
|
|
332
|
+
types2.mutations,
|
|
333
|
+
builders2.buildCollectionTypeMutations(contentType2),
|
|
334
|
+
getConfig(KINDS2.mutation)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const registerSingleType = (contentType2, {
|
|
339
|
+
registry,
|
|
340
|
+
strapi: strapi2,
|
|
341
|
+
builders: builders2
|
|
342
|
+
}) => {
|
|
343
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
344
|
+
const { naming: naming2 } = getService("utils");
|
|
345
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
346
|
+
const extension = getService("extension");
|
|
347
|
+
const types2 = {
|
|
348
|
+
base: naming2.getTypeName(contentType2),
|
|
349
|
+
entity: naming2.getEntityName(contentType2),
|
|
350
|
+
response: naming2.getEntityResponseName(contentType2),
|
|
351
|
+
responseCollection: naming2.getEntityResponseCollectionName(contentType2),
|
|
352
|
+
relationResponseCollection: naming2.getRelationResponseCollectionName(contentType2),
|
|
353
|
+
queries: naming2.getEntityQueriesTypeName(contentType2),
|
|
354
|
+
mutations: naming2.getEntityMutationsTypeName(contentType2)
|
|
355
|
+
};
|
|
356
|
+
const getConfig = (kind) => ({ kind, contentType: contentType2 });
|
|
357
|
+
registry.register(types2.base, builders2.buildTypeDefinition(contentType2), getConfig(KINDS2.type));
|
|
358
|
+
registry.register(
|
|
359
|
+
types2.entity,
|
|
360
|
+
builders2.buildEntityDefinition(contentType2),
|
|
361
|
+
getConfig(KINDS2.entity)
|
|
362
|
+
);
|
|
363
|
+
registry.register(
|
|
364
|
+
types2.response,
|
|
365
|
+
builders2.buildResponseDefinition(contentType2),
|
|
366
|
+
getConfig(KINDS2.entityResponse)
|
|
367
|
+
);
|
|
368
|
+
registry.register(
|
|
369
|
+
types2.responseCollection,
|
|
370
|
+
builders2.buildResponseCollectionDefinition(contentType2),
|
|
371
|
+
getConfig(KINDS2.entityResponseCollection)
|
|
372
|
+
);
|
|
373
|
+
registry.register(
|
|
374
|
+
types2.relationResponseCollection,
|
|
375
|
+
builders2.buildRelationResponseCollectionDefinition(contentType2),
|
|
376
|
+
getConfig(KINDS2.relationResponseCollection)
|
|
377
|
+
);
|
|
378
|
+
if (extension.shadowCRUD(contentType2.uid).areQueriesEnabled()) {
|
|
379
|
+
registry.register(
|
|
380
|
+
types2.queries,
|
|
381
|
+
builders2.buildSingleTypeQueries(contentType2),
|
|
382
|
+
getConfig(KINDS2.query)
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
if (extension.shadowCRUD(contentType2.uid).areMutationsEnabled()) {
|
|
386
|
+
registry.register(
|
|
387
|
+
types2.mutations,
|
|
388
|
+
builders2.buildSingleTypeMutations(contentType2),
|
|
389
|
+
getConfig(KINDS2.mutation)
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
const registerComponent = (contentType2, {
|
|
394
|
+
registry,
|
|
395
|
+
strapi: strapi2,
|
|
396
|
+
builders: builders2
|
|
397
|
+
}) => {
|
|
398
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
399
|
+
const { getComponentName } = getService("utils").naming;
|
|
400
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
401
|
+
const name = getComponentName(contentType2);
|
|
402
|
+
const definition = builders2.buildTypeDefinition(contentType2);
|
|
403
|
+
registry.register(name, definition, { kind: KINDS2.component, contentType: contentType2 });
|
|
404
|
+
};
|
|
405
|
+
const registerPolymorphicContentType = (contentType2, { registry, strapi: strapi2 }) => {
|
|
406
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
407
|
+
const {
|
|
408
|
+
naming: naming2,
|
|
409
|
+
attributes: { isMorphRelation }
|
|
410
|
+
} = getService("utils");
|
|
411
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
412
|
+
const { attributes: attributes2 = {} } = contentType2;
|
|
413
|
+
const morphAttributes = Object.entries(attributes2).filter(
|
|
414
|
+
([, attribute]) => isMorphRelation(attribute)
|
|
415
|
+
);
|
|
416
|
+
for (const [attributeName, attribute] of morphAttributes) {
|
|
417
|
+
const name = naming2.getMorphRelationTypeName(contentType2, attributeName);
|
|
418
|
+
const { target } = attribute;
|
|
419
|
+
if (!Array.isArray(target)) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
const members = target.map((uid) => strapi2.getModel(uid)).map((contentType22) => naming2.getTypeName(contentType22));
|
|
423
|
+
registry.register(
|
|
424
|
+
name,
|
|
425
|
+
nexus.unionType({
|
|
426
|
+
name,
|
|
427
|
+
resolveType(obj) {
|
|
428
|
+
const contentType22 = strapi2.getModel(obj.__type);
|
|
429
|
+
if (!contentType22) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
if (contentType22.modelType === "component") {
|
|
433
|
+
return naming2.getComponentName(contentType22);
|
|
434
|
+
}
|
|
435
|
+
return naming2.getTypeName(contentType22);
|
|
436
|
+
},
|
|
437
|
+
definition(t) {
|
|
438
|
+
t.members(...members);
|
|
439
|
+
}
|
|
440
|
+
}),
|
|
441
|
+
{ kind: KINDS2.morph, contentType: contentType2, attributeName }
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const registerScalars = ({ registry, strapi: strapi2 }) => {
|
|
446
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
447
|
+
const { scalars: scalars2 } = getService("internals");
|
|
448
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
449
|
+
Object.entries(scalars2).forEach(([name, definition]) => {
|
|
450
|
+
registry.register(name, definition, { kind: KINDS2.scalar });
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
const registerInternals = ({ registry, strapi: strapi2 }) => {
|
|
454
|
+
const { buildInternalTypes } = strapi2.plugin("graphql").service("internals");
|
|
455
|
+
const internalTypes = buildInternalTypes({ strapi: strapi2 });
|
|
456
|
+
for (const [kind, definitions] of Object.entries(internalTypes)) {
|
|
457
|
+
registry.registerMany(Object.entries(definitions), { kind });
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
const registerDynamicZonesDefinition$1 = (contentType2, {
|
|
461
|
+
registry,
|
|
462
|
+
strapi: strapi2,
|
|
463
|
+
builders: builders2
|
|
464
|
+
}) => {
|
|
465
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
466
|
+
const {
|
|
467
|
+
naming: naming2,
|
|
468
|
+
attributes: { isDynamicZone }
|
|
469
|
+
} = getService("utils");
|
|
470
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
471
|
+
const { attributes: attributes2 } = contentType2;
|
|
472
|
+
const dynamicZoneAttributes = Object.keys(attributes2).filter(
|
|
473
|
+
(attributeName) => isDynamicZone(attributes2[attributeName])
|
|
474
|
+
);
|
|
475
|
+
for (const attributeName of dynamicZoneAttributes) {
|
|
476
|
+
const attribute = attributes2[attributeName];
|
|
477
|
+
const dzName = naming2.getDynamicZoneName(contentType2, attributeName);
|
|
478
|
+
const dzInputName = naming2.getDynamicZoneInputName(contentType2, attributeName);
|
|
479
|
+
const [type, input] = builders2.buildDynamicZoneDefinition(attribute, dzName, dzInputName);
|
|
480
|
+
const baseConfig = {
|
|
481
|
+
contentType: contentType2,
|
|
482
|
+
attributeName,
|
|
483
|
+
attribute
|
|
484
|
+
};
|
|
485
|
+
registry.register(dzName, type, { kind: KINDS2.dynamicZone, ...baseConfig });
|
|
486
|
+
registry.register(dzInputName, input, { kind: KINDS2.input, ...baseConfig });
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
const registerEnumsDefinition$1 = (contentType2, {
|
|
490
|
+
registry,
|
|
491
|
+
strapi: strapi2,
|
|
492
|
+
builders: builders2
|
|
493
|
+
}) => {
|
|
494
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
495
|
+
const {
|
|
496
|
+
naming: naming2,
|
|
497
|
+
attributes: { isEnumeration }
|
|
498
|
+
} = getService("utils");
|
|
499
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
500
|
+
const { attributes: attributes2 } = contentType2;
|
|
501
|
+
const enumAttributes = Object.keys(attributes2).filter(
|
|
502
|
+
(attributeName) => isEnumeration(attributes2[attributeName])
|
|
503
|
+
);
|
|
504
|
+
for (const attributeName of enumAttributes) {
|
|
505
|
+
const attribute = attributes2[attributeName];
|
|
506
|
+
const enumName = naming2.getEnumName(contentType2, attributeName);
|
|
507
|
+
const enumDefinition = builders2.buildEnumTypeDefinition(attribute, enumName);
|
|
508
|
+
registry.register(enumName, enumDefinition, {
|
|
509
|
+
kind: KINDS2.enum,
|
|
510
|
+
contentType: contentType2,
|
|
511
|
+
attributeName,
|
|
512
|
+
attribute
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const registerInputsDefinition$1 = (contentType2, {
|
|
517
|
+
registry,
|
|
518
|
+
strapi: strapi2,
|
|
519
|
+
builders: builders2
|
|
520
|
+
}) => {
|
|
521
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
522
|
+
const { getComponentInputName, getContentTypeInputName } = getService("utils").naming;
|
|
523
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
524
|
+
const { modelType } = contentType2;
|
|
525
|
+
const type = (modelType === "component" ? getComponentInputName : getContentTypeInputName).call(
|
|
526
|
+
null,
|
|
527
|
+
contentType2
|
|
528
|
+
);
|
|
529
|
+
const definition = builders2.buildInputType(contentType2);
|
|
530
|
+
registry.register(type, definition, { kind: KINDS2.input, contentType: contentType2 });
|
|
531
|
+
};
|
|
532
|
+
const registerFiltersDefinition$1 = (contentType2, {
|
|
533
|
+
registry,
|
|
534
|
+
strapi: strapi2,
|
|
535
|
+
builders: builders2
|
|
536
|
+
}) => {
|
|
537
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
538
|
+
const { getFiltersInputTypeName } = getService("utils").naming;
|
|
539
|
+
const { KINDS: KINDS2 } = getService("constants");
|
|
540
|
+
const type = getFiltersInputTypeName(contentType2);
|
|
541
|
+
const definition = builders2.buildContentTypeFilters(contentType2);
|
|
542
|
+
registry.register(type, definition, { kind: KINDS2.filtersInput, contentType: contentType2 });
|
|
543
|
+
};
|
|
544
|
+
const contentType$1 = {
|
|
545
|
+
registerDynamicZonesDefinition: registerDynamicZonesDefinition$1,
|
|
546
|
+
registerFiltersDefinition: registerFiltersDefinition$1,
|
|
547
|
+
registerInputsDefinition: registerInputsDefinition$1,
|
|
548
|
+
registerEnumsDefinition: registerEnumsDefinition$1
|
|
549
|
+
};
|
|
550
|
+
const {
|
|
551
|
+
registerEnumsDefinition,
|
|
552
|
+
registerInputsDefinition,
|
|
553
|
+
registerFiltersDefinition,
|
|
554
|
+
registerDynamicZonesDefinition
|
|
555
|
+
} = contentType$1;
|
|
556
|
+
const contentAPI = ({ strapi: strapi2 }) => {
|
|
557
|
+
const { mergeSchemas, addResolversToSchema } = require("@graphql-tools/schema");
|
|
558
|
+
const { service: getGraphQLService } = strapi2.plugin("graphql");
|
|
559
|
+
const { config: config2 } = strapi2.plugin("graphql");
|
|
560
|
+
const { KINDS: KINDS2, GENERIC_MORPH_TYPENAME: GENERIC_MORPH_TYPENAME2 } = getGraphQLService("constants");
|
|
561
|
+
const extensionService = getGraphQLService("extension");
|
|
562
|
+
let registry;
|
|
563
|
+
let builders2;
|
|
564
|
+
const buildSchema = () => {
|
|
565
|
+
const isShadowCRUDEnabled = !!config2("shadowCRUD");
|
|
566
|
+
registry = getGraphQLService("type-registry").new();
|
|
567
|
+
builders2 = getGraphQLService("builders").new("content-api", registry);
|
|
568
|
+
registerScalars({ registry, strapi: strapi2 });
|
|
569
|
+
registerInternals({ registry, strapi: strapi2 });
|
|
570
|
+
if (isShadowCRUDEnabled) {
|
|
571
|
+
shadowCRUD();
|
|
572
|
+
}
|
|
573
|
+
const schema = buildMergedSchema({ registry });
|
|
574
|
+
const extension = extensionService.generate({ typeRegistry: registry });
|
|
575
|
+
const schemaWithResolvers = addResolversToSchema(schema, extension.resolvers);
|
|
576
|
+
const outputs = {
|
|
577
|
+
schema: config2("artifacts.schema", false),
|
|
578
|
+
typegen: config2("artifacts.typegen", false)
|
|
579
|
+
};
|
|
580
|
+
const currentEnv = strapi2.config.get("environment");
|
|
581
|
+
const nexusSchema = nexus.makeSchema({
|
|
582
|
+
types: [],
|
|
583
|
+
// Build the schema from the merged GraphQL schema.
|
|
584
|
+
// Since we're passing the schema to the mergeSchema property, it'll transform our SDL type definitions
|
|
585
|
+
// into Nexus type definition, thus allowing them to be handled by Nexus plugins & other processing
|
|
586
|
+
mergeSchema: { schema: schemaWithResolvers },
|
|
587
|
+
// Apply user-defined plugins
|
|
588
|
+
plugins: extension.plugins,
|
|
589
|
+
// Whether to generate artifacts (GraphQL schema, TS types definitions) or not.
|
|
590
|
+
// By default, we generate artifacts only on development environment
|
|
591
|
+
shouldGenerateArtifacts: config2("generateArtifacts", currentEnv === "development"),
|
|
592
|
+
// Artifacts generation configuration
|
|
593
|
+
outputs
|
|
594
|
+
});
|
|
595
|
+
const wrappedNexusSchema = wrapResolvers({ schema: nexusSchema, strapi: strapi2, extension });
|
|
596
|
+
const prunedNexusSchema = utils$3.pruneSchema(wrappedNexusSchema);
|
|
597
|
+
return prunedNexusSchema;
|
|
598
|
+
};
|
|
599
|
+
const buildMergedSchema = ({ registry: registry2 }) => {
|
|
600
|
+
const { types: types2, typeDefs = [] } = extensionService.generate({ typeRegistry: registry2 });
|
|
601
|
+
const nexusSchema = nexus.makeSchema({ types: [registry2.definitions, types2] });
|
|
602
|
+
return mergeSchemas({
|
|
603
|
+
typeDefs,
|
|
604
|
+
// Give access to the shadowCRUD & nexus based types
|
|
605
|
+
// Note: This is necessary so that types defined in SDL can reference types defined with Nexus
|
|
606
|
+
schemas: [nexusSchema]
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
const shadowCRUD = () => {
|
|
610
|
+
const extensionService2 = getGraphQLService("extension");
|
|
611
|
+
const contentTypes = [
|
|
612
|
+
...Object.values(strapi2.components),
|
|
613
|
+
...Object.values(strapi2.contentTypes)
|
|
614
|
+
];
|
|
615
|
+
contentTypes.map(fp.prop("uid")).filter(fp.startsWith("admin::")).forEach((uid) => extensionService2.shadowCRUD(uid).disable());
|
|
616
|
+
const contentTypesWithShadowCRUD = contentTypes.filter(
|
|
617
|
+
(ct) => extensionService2.shadowCRUD(ct.uid).isEnabled()
|
|
618
|
+
);
|
|
619
|
+
registerAPITypes(contentTypesWithShadowCRUD);
|
|
620
|
+
registerMorphTypes(contentTypesWithShadowCRUD);
|
|
621
|
+
};
|
|
622
|
+
const registerAPITypes = (contentTypes) => {
|
|
623
|
+
for (const contentType2 of contentTypes) {
|
|
624
|
+
const { modelType } = contentType2;
|
|
625
|
+
const registerOptions = { registry, strapi: strapi2, builders: builders2 };
|
|
626
|
+
registerEnumsDefinition(contentType2, registerOptions);
|
|
627
|
+
registerDynamicZonesDefinition(contentType2, registerOptions);
|
|
628
|
+
registerFiltersDefinition(contentType2, registerOptions);
|
|
629
|
+
registerInputsDefinition(contentType2, registerOptions);
|
|
630
|
+
if (modelType === "component") {
|
|
631
|
+
registerComponent(contentType2, registerOptions);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
const { kind } = contentType2;
|
|
635
|
+
if (kind === "singleType") {
|
|
636
|
+
registerSingleType(contentType2, registerOptions);
|
|
637
|
+
} else if (kind === "collectionType") {
|
|
638
|
+
registerCollectionType(contentType2, registerOptions);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
const registerMorphTypes = (contentTypes) => {
|
|
643
|
+
const genericMorphType = builders2.buildGenericMorphDefinition();
|
|
644
|
+
registry.register(GENERIC_MORPH_TYPENAME2, genericMorphType, { kind: KINDS2.morph });
|
|
645
|
+
for (const contentType2 of contentTypes) {
|
|
646
|
+
registerPolymorphicContentType(contentType2, { registry, strapi: strapi2 });
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
return { buildSchema };
|
|
650
|
+
};
|
|
651
|
+
const { ApplicationError: ApplicationError$4 } = utils$2.errors;
|
|
652
|
+
const createTypeRegistry = () => {
|
|
653
|
+
const registry = /* @__PURE__ */ new Map();
|
|
654
|
+
const typeRegistry2 = {
|
|
655
|
+
/**
|
|
656
|
+
* Register a new type definition
|
|
657
|
+
*/
|
|
658
|
+
register(name, definition, config2 = {}) {
|
|
659
|
+
if (registry.has(name)) {
|
|
660
|
+
throw new ApplicationError$4(`"${name}" has already been registered`);
|
|
661
|
+
}
|
|
662
|
+
registry.set(name, { name, definition, config: config2 });
|
|
663
|
+
return this;
|
|
664
|
+
},
|
|
665
|
+
/**
|
|
666
|
+
* Register many types definitions at once
|
|
667
|
+
* @param {[string, NexusAcceptedTypeDef][]} definitionsEntries
|
|
668
|
+
* @param {object | function} [config]
|
|
669
|
+
*/
|
|
670
|
+
registerMany(definitionsEntries, config2 = {}) {
|
|
671
|
+
for (const [name, definition] of definitionsEntries) {
|
|
672
|
+
this.register(name, definition, fp.isFunction(config2) ? config2(name, definition) : config2);
|
|
673
|
+
}
|
|
674
|
+
return this;
|
|
675
|
+
},
|
|
676
|
+
/**
|
|
677
|
+
* Check if the given type name has already been added to the registry
|
|
678
|
+
* @param {string} name
|
|
679
|
+
* @return {boolean}
|
|
680
|
+
*/
|
|
681
|
+
has(name) {
|
|
682
|
+
return registry.has(name);
|
|
683
|
+
},
|
|
684
|
+
/**
|
|
685
|
+
* Get the type definition for `name`
|
|
686
|
+
* @param {string} name - The name of the type
|
|
687
|
+
*/
|
|
688
|
+
get(name) {
|
|
689
|
+
return registry.get(name);
|
|
690
|
+
},
|
|
691
|
+
/**
|
|
692
|
+
* Transform and return the registry as an object
|
|
693
|
+
* @return {Object<string, RegisteredTypeDef>}
|
|
694
|
+
*/
|
|
695
|
+
toObject() {
|
|
696
|
+
return Object.fromEntries(registry.entries());
|
|
697
|
+
},
|
|
698
|
+
/**
|
|
699
|
+
* Return the name of every registered type
|
|
700
|
+
* @return {string[]}
|
|
701
|
+
*/
|
|
702
|
+
get types() {
|
|
703
|
+
return Array.from(registry.keys());
|
|
704
|
+
},
|
|
705
|
+
/**
|
|
706
|
+
* Return all the registered definitions as an array
|
|
707
|
+
* @return {RegisteredTypeDef[]}
|
|
708
|
+
*/
|
|
709
|
+
get definitions() {
|
|
710
|
+
return Array.from(registry.values());
|
|
711
|
+
},
|
|
712
|
+
/**
|
|
713
|
+
* Filter and return the types definitions that matches the given predicate
|
|
714
|
+
* @param {function(RegisteredTypeDef): boolean} predicate
|
|
715
|
+
* @return {RegisteredTypeDef[]}
|
|
716
|
+
*/
|
|
717
|
+
where(predicate) {
|
|
718
|
+
return this.definitions.filter(predicate);
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
return typeRegistry2;
|
|
722
|
+
};
|
|
723
|
+
const typeRegistry = () => ({
|
|
724
|
+
new: createTypeRegistry
|
|
725
|
+
});
|
|
726
|
+
const { ApplicationError: ApplicationError$3 } = utils$2.errors;
|
|
727
|
+
const strapiScalarToGraphQLScalar = ({ strapi: strapi2 }) => {
|
|
728
|
+
const { STRAPI_SCALARS: STRAPI_SCALARS2, SCALARS_ASSOCIATIONS: SCALARS_ASSOCIATIONS2 } = strapi2.plugin("graphql").service("constants");
|
|
729
|
+
const missingStrapiScalars = fp.difference(STRAPI_SCALARS2, Object.keys(SCALARS_ASSOCIATIONS2));
|
|
730
|
+
if (missingStrapiScalars.length > 0) {
|
|
731
|
+
throw new ApplicationError$3("Some Strapi scalars are not handled in the GraphQL scalars mapper");
|
|
732
|
+
}
|
|
733
|
+
return {
|
|
734
|
+
/**
|
|
735
|
+
* Used to transform a Strapi scalar type into its GraphQL equivalent
|
|
736
|
+
*/
|
|
737
|
+
strapiScalarToGraphQLScalar(strapiScalar) {
|
|
738
|
+
return fp.get(strapiScalar, SCALARS_ASSOCIATIONS2);
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
const virtualScalarAttributes = ["id"];
|
|
743
|
+
const graphQLFiltersToStrapiQuery = ({ strapi: strapi2 }) => {
|
|
744
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
745
|
+
const recursivelyReplaceScalarOperators = (data) => {
|
|
746
|
+
const { operators: operators2 } = getService("builders").filters;
|
|
747
|
+
if (Array.isArray(data)) {
|
|
748
|
+
return data.map(recursivelyReplaceScalarOperators);
|
|
749
|
+
}
|
|
750
|
+
if (fp.isDate(data) || !fp.isObject(data)) {
|
|
751
|
+
return data;
|
|
752
|
+
}
|
|
753
|
+
const result = {};
|
|
754
|
+
for (const [key, value] of Object.entries(data)) {
|
|
755
|
+
const isOperator = !!operators2[key];
|
|
756
|
+
const newKey = isOperator ? operators2[key].strapiOperator : key;
|
|
757
|
+
result[newKey] = recursivelyReplaceScalarOperators(value);
|
|
758
|
+
}
|
|
759
|
+
return result;
|
|
760
|
+
};
|
|
761
|
+
return {
|
|
762
|
+
/**
|
|
763
|
+
* Transform one or many GraphQL filters object into a valid Strapi query
|
|
764
|
+
* @param {object | object[]} filters
|
|
765
|
+
* @param {object} contentType
|
|
766
|
+
* @return {object | object[]}
|
|
767
|
+
*/
|
|
768
|
+
graphQLFiltersToStrapiQuery(filters2, contentType2) {
|
|
769
|
+
const { isStrapiScalar, isMedia, isRelation, isComponent } = getService("utils").attributes;
|
|
770
|
+
const { operators: operators2 } = getService("builders").filters;
|
|
771
|
+
const ROOT_LEVEL_OPERATORS = [operators2.and, operators2.or, operators2.not];
|
|
772
|
+
if (fp.isNil(filters2)) {
|
|
773
|
+
return {};
|
|
774
|
+
}
|
|
775
|
+
if (Array.isArray(filters2)) {
|
|
776
|
+
return filters2.map(
|
|
777
|
+
(filtersItem) => this.graphQLFiltersToStrapiQuery(filtersItem, contentType2)
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
const resultMap = {};
|
|
781
|
+
const { attributes: attributes2 } = contentType2;
|
|
782
|
+
const isAttribute = (attributeName) => {
|
|
783
|
+
return virtualScalarAttributes.includes(attributeName) || fp.has(attributeName, attributes2);
|
|
784
|
+
};
|
|
785
|
+
for (const [key, value] of Object.entries(filters2)) {
|
|
786
|
+
if (isAttribute(key)) {
|
|
787
|
+
const attribute = attributes2[key];
|
|
788
|
+
if (virtualScalarAttributes.includes(key) || isStrapiScalar(attribute)) {
|
|
789
|
+
resultMap[key] = recursivelyReplaceScalarOperators(value);
|
|
790
|
+
} else if (isRelation(attribute) || isMedia(attribute)) {
|
|
791
|
+
const relModel = strapi2.getModel(attribute.target);
|
|
792
|
+
resultMap[key] = this.graphQLFiltersToStrapiQuery(value, relModel);
|
|
793
|
+
} else if (isComponent(attribute)) {
|
|
794
|
+
const componentModel = strapi2.getModel(attribute.component);
|
|
795
|
+
resultMap[key] = this.graphQLFiltersToStrapiQuery(value, componentModel);
|
|
796
|
+
}
|
|
797
|
+
} else {
|
|
798
|
+
const rootLevelOperator = ROOT_LEVEL_OPERATORS.find(fp.propEq("fieldName", key));
|
|
799
|
+
if (rootLevelOperator) {
|
|
800
|
+
const { strapiOperator } = rootLevelOperator;
|
|
801
|
+
resultMap[strapiOperator] = this.graphQLFiltersToStrapiQuery(value, contentType2);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return resultMap;
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
};
|
|
809
|
+
const graphqlScalarToOperators = ({ strapi: strapi2 }) => ({
|
|
810
|
+
graphqlScalarToOperators(graphqlScalar) {
|
|
811
|
+
const { GRAPHQL_SCALAR_OPERATORS: GRAPHQL_SCALAR_OPERATORS2 } = strapi2.plugin("graphql").service("constants");
|
|
812
|
+
const { operators: operators2 } = strapi2.plugin("graphql").service("builders").filters;
|
|
813
|
+
const associations = fp.mapValues(
|
|
814
|
+
fp.map((operatorName) => operators2[operatorName]),
|
|
815
|
+
GRAPHQL_SCALAR_OPERATORS2
|
|
816
|
+
);
|
|
817
|
+
return fp.get(graphqlScalar, associations);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
const entityToResponseEntity = (entity2) => ({
|
|
821
|
+
id: entity2.id,
|
|
822
|
+
attributes: entity2
|
|
823
|
+
});
|
|
824
|
+
const entitiesToResponseEntities = fp.map(entityToResponseEntity);
|
|
825
|
+
const entityToResponseEntity$1 = () => ({
|
|
826
|
+
entityToResponseEntity,
|
|
827
|
+
entitiesToResponseEntities
|
|
828
|
+
});
|
|
829
|
+
const mappers = (context) => ({
|
|
830
|
+
...strapiScalarToGraphQLScalar(context),
|
|
831
|
+
...graphQLFiltersToStrapiQuery(context),
|
|
832
|
+
...graphqlScalarToOperators(context),
|
|
833
|
+
...entityToResponseEntity$1()
|
|
834
|
+
});
|
|
835
|
+
const attributes = ({ strapi: strapi2 }) => {
|
|
836
|
+
const isStrapiScalar = (attribute) => {
|
|
837
|
+
return strapi2.plugin("graphql").service("constants").STRAPI_SCALARS.includes(attribute.type);
|
|
838
|
+
};
|
|
839
|
+
const isGraphQLScalar = (attribute) => {
|
|
840
|
+
return strapi2.plugin("graphql").service("constants").GRAPHQL_SCALARS.includes(attribute.type);
|
|
841
|
+
};
|
|
842
|
+
const isMorphRelation = (attribute) => {
|
|
843
|
+
return attribute.type === "relation" && attribute.relation.includes("morph");
|
|
844
|
+
};
|
|
845
|
+
const isMedia = fp.propEq("type", "media");
|
|
846
|
+
const isRelation = fp.propEq("type", "relation");
|
|
847
|
+
const isEnumeration = fp.propEq("type", "enumeration");
|
|
848
|
+
const isComponent = fp.propEq("type", "component");
|
|
849
|
+
const isDynamicZone = fp.propEq("type", "dynamiczone");
|
|
850
|
+
return {
|
|
851
|
+
isStrapiScalar,
|
|
852
|
+
isGraphQLScalar,
|
|
853
|
+
isMorphRelation,
|
|
854
|
+
isMedia,
|
|
855
|
+
isRelation,
|
|
856
|
+
isEnumeration,
|
|
857
|
+
isComponent,
|
|
858
|
+
isDynamicZone
|
|
859
|
+
};
|
|
860
|
+
};
|
|
861
|
+
const { ApplicationError: ApplicationError$2 } = utils$2.errors;
|
|
862
|
+
const naming = ({ strapi: strapi2 }) => {
|
|
863
|
+
const getEnumName = (contentType2, attributeName) => {
|
|
864
|
+
const { attributes: attributes2 } = contentType2;
|
|
865
|
+
const { enumName } = attributes2[attributeName];
|
|
866
|
+
const { modelType } = contentType2;
|
|
867
|
+
const typeName = modelType === "component" ? getComponentName(contentType2) : getTypeName(contentType2);
|
|
868
|
+
const defaultEnumName = `ENUM_${typeName.toUpperCase()}_${attributeName.toUpperCase()}`;
|
|
869
|
+
return enumName || defaultEnumName;
|
|
870
|
+
};
|
|
871
|
+
const getTypeName = (contentType2, {
|
|
872
|
+
plurality = "singular"
|
|
873
|
+
} = {}) => {
|
|
874
|
+
const plugin = fp.get("plugin", contentType2);
|
|
875
|
+
const modelName = fp.get("modelName", contentType2);
|
|
876
|
+
const name = plurality === "singular" ? fp.get("info.singularName", contentType2) : fp.get("info.pluralName", contentType2);
|
|
877
|
+
const transformedPlugin = fp.upperFirst(fp.camelCase(plugin));
|
|
878
|
+
const transformedModelName = fp.upperFirst(fp.camelCase(name || pluralize.singular(modelName)));
|
|
879
|
+
return `${transformedPlugin}${transformedModelName}`;
|
|
880
|
+
};
|
|
881
|
+
const getEntityName = (contentType2) => {
|
|
882
|
+
return `${getTypeName(contentType2)}Entity`;
|
|
883
|
+
};
|
|
884
|
+
const getEntityMetaName = (contentType2) => {
|
|
885
|
+
return `${getEntityName(contentType2)}Meta`;
|
|
886
|
+
};
|
|
887
|
+
const getEntityResponseName = (contentType2) => {
|
|
888
|
+
return `${getEntityName(contentType2)}Response`;
|
|
889
|
+
};
|
|
890
|
+
const getEntityResponseCollectionName = (contentType2) => {
|
|
891
|
+
return `${getEntityName(contentType2)}ResponseCollection`;
|
|
892
|
+
};
|
|
893
|
+
const getRelationResponseCollectionName = (contentType2) => {
|
|
894
|
+
return `${getTypeName(contentType2)}RelationResponseCollection`;
|
|
895
|
+
};
|
|
896
|
+
const getComponentName = (contentType2) => {
|
|
897
|
+
return contentType2.globalId;
|
|
898
|
+
};
|
|
899
|
+
const getComponentNameFromAttribute = (attribute) => {
|
|
900
|
+
return strapi2.components[attribute.component].globalId;
|
|
901
|
+
};
|
|
902
|
+
const getDynamicZoneName = (contentType2, attributeName) => {
|
|
903
|
+
const typeName = getTypeName(contentType2);
|
|
904
|
+
const dzName = fp.upperFirst(fp.camelCase(attributeName));
|
|
905
|
+
const suffix = "DynamicZone";
|
|
906
|
+
return `${typeName}${dzName}${suffix}`;
|
|
907
|
+
};
|
|
908
|
+
const getDynamicZoneInputName = (contentType2, attributeName) => {
|
|
909
|
+
const dzName = getDynamicZoneName(contentType2, attributeName);
|
|
910
|
+
return `${dzName}Input`;
|
|
911
|
+
};
|
|
912
|
+
const getComponentInputName = (contentType2) => {
|
|
913
|
+
const componentName = getComponentName(contentType2);
|
|
914
|
+
return `${componentName}Input`;
|
|
915
|
+
};
|
|
916
|
+
const getContentTypeInputName = (contentType2) => {
|
|
917
|
+
const typeName = getTypeName(contentType2);
|
|
918
|
+
return `${typeName}Input`;
|
|
919
|
+
};
|
|
920
|
+
const getEntityQueriesTypeName = (contentType2) => {
|
|
921
|
+
return `${getEntityName(contentType2)}Queries`;
|
|
922
|
+
};
|
|
923
|
+
const getEntityMutationsTypeName = (contentType2) => {
|
|
924
|
+
return `${getEntityName(contentType2)}Mutations`;
|
|
925
|
+
};
|
|
926
|
+
const getFiltersInputTypeName = (contentType2) => {
|
|
927
|
+
const isComponent = contentType2.modelType === "component";
|
|
928
|
+
const baseName = isComponent ? getComponentName(contentType2) : getTypeName(contentType2);
|
|
929
|
+
return `${baseName}FiltersInput`;
|
|
930
|
+
};
|
|
931
|
+
const getScalarFilterInputTypeName = (scalarType) => {
|
|
932
|
+
return `${scalarType}FilterInput`;
|
|
933
|
+
};
|
|
934
|
+
const getMorphRelationTypeName = (contentType2, attributeName) => {
|
|
935
|
+
const typeName = getTypeName(contentType2);
|
|
936
|
+
const formattedAttr = fp.upperFirst(fp.camelCase(attributeName));
|
|
937
|
+
return `${typeName}${formattedAttr}Morph`;
|
|
938
|
+
};
|
|
939
|
+
const buildCustomTypeNameGenerator = (options) => {
|
|
940
|
+
const { prefix = "", suffix = "", plurality = "singular", firstLetterCase = "upper" } = options;
|
|
941
|
+
if (!["plural", "singular"].includes(plurality)) {
|
|
942
|
+
throw new ApplicationError$2(
|
|
943
|
+
`"plurality" param must be either "plural" or "singular", but got: "${plurality}"`
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
const getCustomTypeName = fp.pipe(
|
|
947
|
+
(ct) => getTypeName(ct, { plurality }),
|
|
948
|
+
firstLetterCase === "upper" ? fp.upperFirst : fp.lowerFirst
|
|
949
|
+
);
|
|
950
|
+
return (contentType2) => `${prefix}${getCustomTypeName(contentType2)}${suffix}`;
|
|
951
|
+
};
|
|
952
|
+
const getFindQueryName = buildCustomTypeNameGenerator({
|
|
953
|
+
plurality: "plural",
|
|
954
|
+
firstLetterCase: "lower"
|
|
955
|
+
});
|
|
956
|
+
const getFindOneQueryName = buildCustomTypeNameGenerator({ firstLetterCase: "lower" });
|
|
957
|
+
const getCreateMutationTypeName = buildCustomTypeNameGenerator({
|
|
958
|
+
prefix: "create",
|
|
959
|
+
firstLetterCase: "upper"
|
|
960
|
+
});
|
|
961
|
+
const getUpdateMutationTypeName = buildCustomTypeNameGenerator({
|
|
962
|
+
prefix: "update",
|
|
963
|
+
firstLetterCase: "upper"
|
|
964
|
+
});
|
|
965
|
+
const getDeleteMutationTypeName = buildCustomTypeNameGenerator({
|
|
966
|
+
prefix: "delete",
|
|
967
|
+
firstLetterCase: "upper"
|
|
968
|
+
});
|
|
969
|
+
return {
|
|
970
|
+
getEnumName,
|
|
971
|
+
getTypeName,
|
|
972
|
+
getEntityName,
|
|
973
|
+
getEntityMetaName,
|
|
974
|
+
getEntityResponseName,
|
|
975
|
+
getEntityResponseCollectionName,
|
|
976
|
+
getRelationResponseCollectionName,
|
|
977
|
+
getComponentName,
|
|
978
|
+
getComponentNameFromAttribute,
|
|
979
|
+
getDynamicZoneName,
|
|
980
|
+
getDynamicZoneInputName,
|
|
981
|
+
getComponentInputName,
|
|
982
|
+
getContentTypeInputName,
|
|
983
|
+
getEntityQueriesTypeName,
|
|
984
|
+
getEntityMutationsTypeName,
|
|
985
|
+
getFiltersInputTypeName,
|
|
986
|
+
getScalarFilterInputTypeName,
|
|
987
|
+
getMorphRelationTypeName,
|
|
988
|
+
buildCustomTypeNameGenerator,
|
|
989
|
+
getFindQueryName,
|
|
990
|
+
getFindOneQueryName,
|
|
991
|
+
getCreateMutationTypeName,
|
|
992
|
+
getUpdateMutationTypeName,
|
|
993
|
+
getDeleteMutationTypeName
|
|
994
|
+
};
|
|
995
|
+
};
|
|
996
|
+
const utils$1 = (context) => ({
|
|
997
|
+
naming: naming(context),
|
|
998
|
+
attributes: attributes(context),
|
|
999
|
+
mappers: mappers(context)
|
|
1000
|
+
});
|
|
1001
|
+
const PAGINATION_TYPE_NAME = "Pagination";
|
|
1002
|
+
const PUBLICATION_STATE_TYPE_NAME = "PublicationState";
|
|
1003
|
+
const ERROR_TYPE_NAME = "Error";
|
|
1004
|
+
const RESPONSE_COLLECTION_META_TYPE_NAME = "ResponseCollectionMeta";
|
|
1005
|
+
const GRAPHQL_SCALARS = [
|
|
1006
|
+
"ID",
|
|
1007
|
+
"Boolean",
|
|
1008
|
+
"Int",
|
|
1009
|
+
"String",
|
|
1010
|
+
"Long",
|
|
1011
|
+
"Float",
|
|
1012
|
+
"JSON",
|
|
1013
|
+
"Date",
|
|
1014
|
+
"Time",
|
|
1015
|
+
"DateTime"
|
|
1016
|
+
];
|
|
1017
|
+
const STRAPI_SCALARS = [
|
|
1018
|
+
"boolean",
|
|
1019
|
+
"integer",
|
|
1020
|
+
"string",
|
|
1021
|
+
"richtext",
|
|
1022
|
+
"blocks",
|
|
1023
|
+
"enumeration",
|
|
1024
|
+
"biginteger",
|
|
1025
|
+
"float",
|
|
1026
|
+
"decimal",
|
|
1027
|
+
"json",
|
|
1028
|
+
"date",
|
|
1029
|
+
"time",
|
|
1030
|
+
"datetime",
|
|
1031
|
+
"timestamp",
|
|
1032
|
+
"uid",
|
|
1033
|
+
"email",
|
|
1034
|
+
"password",
|
|
1035
|
+
"text"
|
|
1036
|
+
];
|
|
1037
|
+
const SCALARS_ASSOCIATIONS = {
|
|
1038
|
+
uid: "String",
|
|
1039
|
+
email: "String",
|
|
1040
|
+
password: "String",
|
|
1041
|
+
text: "String",
|
|
1042
|
+
boolean: "Boolean",
|
|
1043
|
+
integer: "Int",
|
|
1044
|
+
string: "String",
|
|
1045
|
+
enumeration: "String",
|
|
1046
|
+
richtext: "String",
|
|
1047
|
+
blocks: "JSON",
|
|
1048
|
+
biginteger: "Long",
|
|
1049
|
+
float: "Float",
|
|
1050
|
+
decimal: "Float",
|
|
1051
|
+
json: "JSON",
|
|
1052
|
+
date: "Date",
|
|
1053
|
+
time: "Time",
|
|
1054
|
+
datetime: "DateTime",
|
|
1055
|
+
timestamp: "DateTime"
|
|
1056
|
+
};
|
|
1057
|
+
const GENERIC_MORPH_TYPENAME = "GenericMorph";
|
|
1058
|
+
const KINDS = {
|
|
1059
|
+
type: "type",
|
|
1060
|
+
component: "component",
|
|
1061
|
+
dynamicZone: "dynamic-zone",
|
|
1062
|
+
enum: "enum",
|
|
1063
|
+
entity: "entity",
|
|
1064
|
+
entityResponse: "entity-response",
|
|
1065
|
+
entityResponseCollection: "entity-response-collection",
|
|
1066
|
+
relationResponseCollection: "relation-response-collection",
|
|
1067
|
+
query: "query",
|
|
1068
|
+
mutation: "mutation",
|
|
1069
|
+
input: "input",
|
|
1070
|
+
filtersInput: "filters-input",
|
|
1071
|
+
scalar: "scalar",
|
|
1072
|
+
morph: "polymorphic",
|
|
1073
|
+
internal: "internal"
|
|
1074
|
+
};
|
|
1075
|
+
const allOperators = [
|
|
1076
|
+
"and",
|
|
1077
|
+
"or",
|
|
1078
|
+
"not",
|
|
1079
|
+
"eq",
|
|
1080
|
+
"eqi",
|
|
1081
|
+
"ne",
|
|
1082
|
+
"nei",
|
|
1083
|
+
"startsWith",
|
|
1084
|
+
"endsWith",
|
|
1085
|
+
"contains",
|
|
1086
|
+
"notContains",
|
|
1087
|
+
"containsi",
|
|
1088
|
+
"notContainsi",
|
|
1089
|
+
"gt",
|
|
1090
|
+
"gte",
|
|
1091
|
+
"lt",
|
|
1092
|
+
"lte",
|
|
1093
|
+
"null",
|
|
1094
|
+
"notNull",
|
|
1095
|
+
"in",
|
|
1096
|
+
"notIn",
|
|
1097
|
+
"between"
|
|
1098
|
+
];
|
|
1099
|
+
const GRAPHQL_SCALAR_OPERATORS = {
|
|
1100
|
+
// ID
|
|
1101
|
+
ID: allOperators,
|
|
1102
|
+
// Booleans
|
|
1103
|
+
Boolean: allOperators,
|
|
1104
|
+
// Strings
|
|
1105
|
+
String: allOperators,
|
|
1106
|
+
// Numbers
|
|
1107
|
+
Int: allOperators,
|
|
1108
|
+
Long: allOperators,
|
|
1109
|
+
Float: allOperators,
|
|
1110
|
+
// Dates
|
|
1111
|
+
Date: allOperators,
|
|
1112
|
+
Time: allOperators,
|
|
1113
|
+
DateTime: allOperators,
|
|
1114
|
+
// Others
|
|
1115
|
+
JSON: allOperators
|
|
1116
|
+
};
|
|
1117
|
+
const ERROR_CODES = {
|
|
1118
|
+
emptyDynamicZone: "dynamiczone.empty"
|
|
1119
|
+
};
|
|
1120
|
+
const constants = () => ({
|
|
1121
|
+
PAGINATION_TYPE_NAME,
|
|
1122
|
+
RESPONSE_COLLECTION_META_TYPE_NAME,
|
|
1123
|
+
PUBLICATION_STATE_TYPE_NAME,
|
|
1124
|
+
GRAPHQL_SCALARS,
|
|
1125
|
+
STRAPI_SCALARS,
|
|
1126
|
+
GENERIC_MORPH_TYPENAME,
|
|
1127
|
+
KINDS,
|
|
1128
|
+
GRAPHQL_SCALAR_OPERATORS,
|
|
1129
|
+
SCALARS_ASSOCIATIONS,
|
|
1130
|
+
ERROR_CODES,
|
|
1131
|
+
ERROR_TYPE_NAME
|
|
1132
|
+
});
|
|
1133
|
+
const SortArg = nexus.arg({
|
|
1134
|
+
type: nexus.list("String"),
|
|
1135
|
+
default: []
|
|
1136
|
+
});
|
|
1137
|
+
const publicationState$1 = ({ strapi: strapi2 }) => {
|
|
1138
|
+
const { PUBLICATION_STATE_TYPE_NAME: PUBLICATION_STATE_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1139
|
+
return nexus.arg({
|
|
1140
|
+
type: PUBLICATION_STATE_TYPE_NAME2,
|
|
1141
|
+
default: "live"
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
const PaginationInputType = nexus.inputObjectType({
|
|
1145
|
+
name: "PaginationArg",
|
|
1146
|
+
definition(t) {
|
|
1147
|
+
t.int("page");
|
|
1148
|
+
t.int("pageSize");
|
|
1149
|
+
t.int("start");
|
|
1150
|
+
t.int("limit");
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
const PaginationArg = nexus.arg({
|
|
1154
|
+
type: PaginationInputType,
|
|
1155
|
+
default: {}
|
|
1156
|
+
});
|
|
1157
|
+
const args = (context) => ({
|
|
1158
|
+
SortArg,
|
|
1159
|
+
PaginationArg,
|
|
1160
|
+
PublicationStateArg: publicationState$1(context)
|
|
1161
|
+
});
|
|
1162
|
+
const { ValidationError: ValidationError$2 } = utils$2.errors;
|
|
1163
|
+
const TimeScalar = new graphql.GraphQLScalarType({
|
|
1164
|
+
name: "Time",
|
|
1165
|
+
description: "A time string with format HH:mm:ss.SSS",
|
|
1166
|
+
serialize(value) {
|
|
1167
|
+
return utils$2.parseType({ type: "time", value });
|
|
1168
|
+
},
|
|
1169
|
+
parseValue(value) {
|
|
1170
|
+
return utils$2.parseType({ type: "time", value });
|
|
1171
|
+
},
|
|
1172
|
+
parseLiteral(ast) {
|
|
1173
|
+
if (ast.kind !== graphql.Kind.STRING) {
|
|
1174
|
+
throw new ValidationError$2("Time cannot represent non string type");
|
|
1175
|
+
}
|
|
1176
|
+
const { value } = ast;
|
|
1177
|
+
return utils$2.parseType({ type: "time", value });
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
const parseAndCast = (parseFn) => (...args2) => {
|
|
1181
|
+
const parsedValue = parseFn(...args2);
|
|
1182
|
+
if (parsedValue instanceof Date) {
|
|
1183
|
+
return parsedValue.toISOString().split("T")[0];
|
|
1184
|
+
}
|
|
1185
|
+
return parsedValue;
|
|
1186
|
+
};
|
|
1187
|
+
graphqlScalars.GraphQLDate.parseValue = parseAndCast(graphqlScalars.GraphQLDate.parseValue);
|
|
1188
|
+
graphqlScalars.GraphQLDate.parseLiteral = parseAndCast(graphqlScalars.GraphQLDate.parseLiteral);
|
|
1189
|
+
const scalars = () => ({
|
|
1190
|
+
JSON: nexus.asNexusMethod(graphqlScalars.GraphQLJSON, "json"),
|
|
1191
|
+
DateTime: nexus.asNexusMethod(graphqlScalars.GraphQLDateTime, "dateTime"),
|
|
1192
|
+
Time: nexus.asNexusMethod(TimeScalar, "time"),
|
|
1193
|
+
Date: nexus.asNexusMethod(graphqlScalars.GraphQLDate, "date"),
|
|
1194
|
+
Long: nexus.asNexusMethod(graphqlScalars.GraphQLLong, "long"),
|
|
1195
|
+
Upload: nexus.asNexusMethod(GraphQLUpload__default.default, "upload")
|
|
1196
|
+
});
|
|
1197
|
+
const pagination = ({ strapi: strapi2 }) => {
|
|
1198
|
+
const { PAGINATION_TYPE_NAME: PAGINATION_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1199
|
+
return {
|
|
1200
|
+
/**
|
|
1201
|
+
* Type definition for a Pagination object
|
|
1202
|
+
* @type {NexusObjectTypeDef}
|
|
1203
|
+
*/
|
|
1204
|
+
Pagination: nexus.objectType({
|
|
1205
|
+
name: PAGINATION_TYPE_NAME2,
|
|
1206
|
+
definition(t) {
|
|
1207
|
+
t.nonNull.int("total");
|
|
1208
|
+
t.nonNull.int("page");
|
|
1209
|
+
t.nonNull.int("pageSize");
|
|
1210
|
+
t.nonNull.int("pageCount");
|
|
1211
|
+
}
|
|
1212
|
+
})
|
|
1213
|
+
};
|
|
1214
|
+
};
|
|
1215
|
+
const buildResponseCollectionMeta = ({ strapi: strapi2 }) => {
|
|
1216
|
+
const { RESPONSE_COLLECTION_META_TYPE_NAME: RESPONSE_COLLECTION_META_TYPE_NAME2, PAGINATION_TYPE_NAME: PAGINATION_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1217
|
+
return {
|
|
1218
|
+
/**
|
|
1219
|
+
* A shared type definition used in EntitiesResponseCollection
|
|
1220
|
+
* to have information about the collection as a whole
|
|
1221
|
+
* @type {NexusObjectTypeDef}
|
|
1222
|
+
*/
|
|
1223
|
+
ResponseCollectionMeta: nexus.objectType({
|
|
1224
|
+
name: RESPONSE_COLLECTION_META_TYPE_NAME2,
|
|
1225
|
+
definition(t) {
|
|
1226
|
+
t.nonNull.field("pagination", {
|
|
1227
|
+
type: PAGINATION_TYPE_NAME2,
|
|
1228
|
+
async resolve(parent, _childArgs, ctx) {
|
|
1229
|
+
const { args: args2, resourceUID } = parent;
|
|
1230
|
+
const { start, limit } = args2;
|
|
1231
|
+
const safeLimit = Math.max(limit, 1);
|
|
1232
|
+
const contentType2 = strapi2.getModel(resourceUID);
|
|
1233
|
+
await utils$2.validate.contentAPI.query(args2, contentType2, {
|
|
1234
|
+
auth: ctx?.state?.auth
|
|
1235
|
+
});
|
|
1236
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(args2, contentType2, {
|
|
1237
|
+
auth: ctx?.state?.auth
|
|
1238
|
+
});
|
|
1239
|
+
const total = await strapi2.entityService.count(resourceUID, sanitizedQuery);
|
|
1240
|
+
const pageSize = limit === -1 ? total - start : safeLimit;
|
|
1241
|
+
const pageCount = limit === -1 ? safeLimit : Math.ceil(total / safeLimit);
|
|
1242
|
+
const page = limit === -1 ? safeLimit : Math.floor(start / safeLimit) + 1;
|
|
1243
|
+
return { total, page, pageSize, pageCount };
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
})
|
|
1248
|
+
};
|
|
1249
|
+
};
|
|
1250
|
+
const publicationState = ({ strapi: strapi2 }) => {
|
|
1251
|
+
const { PUBLICATION_STATE_TYPE_NAME: PUBLICATION_STATE_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1252
|
+
return {
|
|
1253
|
+
/**
|
|
1254
|
+
* An enum type definition representing a publication state
|
|
1255
|
+
* @type {NexusEnumTypeDef}
|
|
1256
|
+
*/
|
|
1257
|
+
PublicationState: nexus.enumType({
|
|
1258
|
+
name: PUBLICATION_STATE_TYPE_NAME2,
|
|
1259
|
+
members: {
|
|
1260
|
+
// Published only
|
|
1261
|
+
LIVE: "live",
|
|
1262
|
+
// Published & draft
|
|
1263
|
+
PREVIEW: "preview"
|
|
1264
|
+
}
|
|
1265
|
+
})
|
|
1266
|
+
};
|
|
1267
|
+
};
|
|
1268
|
+
const buildScalarFilters = ({ strapi: strapi2 }) => {
|
|
1269
|
+
const { naming: naming2, mappers: mappers2 } = strapi2.plugin("graphql").service("utils");
|
|
1270
|
+
const { helpers: helpers2 } = strapi2.plugin("graphql").service("internals");
|
|
1271
|
+
return helpers2.getEnabledScalars().reduce((acc, type) => {
|
|
1272
|
+
const operators2 = mappers2.graphqlScalarToOperators(type);
|
|
1273
|
+
const typeName = naming2.getScalarFilterInputTypeName(type);
|
|
1274
|
+
if (!operators2 || operators2.length === 0) {
|
|
1275
|
+
return acc;
|
|
1276
|
+
}
|
|
1277
|
+
return {
|
|
1278
|
+
...acc,
|
|
1279
|
+
[typeName]: nexus.inputObjectType({
|
|
1280
|
+
name: typeName,
|
|
1281
|
+
definition(t) {
|
|
1282
|
+
for (const operator of operators2) {
|
|
1283
|
+
operator.add(t, type);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
})
|
|
1287
|
+
};
|
|
1288
|
+
}, {});
|
|
1289
|
+
};
|
|
1290
|
+
const filters$1 = (context) => ({
|
|
1291
|
+
scalars: buildScalarFilters(context)
|
|
1292
|
+
});
|
|
1293
|
+
const { ValidationError: ValidationError$1 } = utils$2.errors;
|
|
1294
|
+
const error = ({ strapi: strapi2 }) => {
|
|
1295
|
+
const { ERROR_CODES: ERROR_CODES2, ERROR_TYPE_NAME: ERROR_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1296
|
+
return nexus.objectType({
|
|
1297
|
+
name: ERROR_TYPE_NAME2,
|
|
1298
|
+
definition(t) {
|
|
1299
|
+
t.nonNull.string("code", {
|
|
1300
|
+
resolve(parent) {
|
|
1301
|
+
const code = fp.get("code", parent);
|
|
1302
|
+
const isValidPlaceholderCode = Object.values(ERROR_CODES2).includes(code);
|
|
1303
|
+
if (!isValidPlaceholderCode) {
|
|
1304
|
+
throw new ValidationError$1(`"${code}" is not a valid code value`);
|
|
1305
|
+
}
|
|
1306
|
+
return code;
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
t.string("message");
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
};
|
|
1313
|
+
const types = (context) => () => {
|
|
1314
|
+
const { strapi: strapi2 } = context;
|
|
1315
|
+
const { KINDS: KINDS2 } = strapi2.plugin("graphql").service("constants");
|
|
1316
|
+
return {
|
|
1317
|
+
[KINDS2.internal]: {
|
|
1318
|
+
error: error(context),
|
|
1319
|
+
pagination: pagination(context),
|
|
1320
|
+
responseCollectionMeta: buildResponseCollectionMeta(context)
|
|
1321
|
+
},
|
|
1322
|
+
[KINDS2.enum]: {
|
|
1323
|
+
publicationState: publicationState(context)
|
|
1324
|
+
},
|
|
1325
|
+
[KINDS2.filtersInput]: {
|
|
1326
|
+
...filters$1(context)
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
};
|
|
1330
|
+
const getEnabledScalars = ({ strapi: strapi2 }) => () => {
|
|
1331
|
+
const { GRAPHQL_SCALAR_OPERATORS: GRAPHQL_SCALAR_OPERATORS2 } = strapi2.plugin("graphql").service("constants");
|
|
1332
|
+
return Object.entries(GRAPHQL_SCALAR_OPERATORS2).filter(([, value]) => value.length > 0).map(fp.first);
|
|
1333
|
+
};
|
|
1334
|
+
const helpers = (context) => ({
|
|
1335
|
+
getEnabledScalars: getEnabledScalars(context)
|
|
1336
|
+
});
|
|
1337
|
+
const internals = (context) => ({
|
|
1338
|
+
args: args(context),
|
|
1339
|
+
scalars: scalars(),
|
|
1340
|
+
buildInternalTypes: types(context),
|
|
1341
|
+
helpers: helpers(context)
|
|
1342
|
+
});
|
|
1343
|
+
const buildEnumTypeDefinition = (definition, name) => {
|
|
1344
|
+
return nexus.enumType({
|
|
1345
|
+
name,
|
|
1346
|
+
members: definition.enum.reduce(
|
|
1347
|
+
(acc, value) => fp.set(utils$2.toRegressedEnumValue(value), value, acc),
|
|
1348
|
+
{}
|
|
1349
|
+
)
|
|
1350
|
+
});
|
|
1351
|
+
};
|
|
1352
|
+
const enums = () => ({
|
|
1353
|
+
buildEnumTypeDefinition
|
|
1354
|
+
});
|
|
1355
|
+
const { ApplicationError: ApplicationError$1 } = utils$2.errors;
|
|
1356
|
+
const dynamicZone = ({ strapi: strapi2 }) => {
|
|
1357
|
+
const buildTypeDefinition = (name, components) => {
|
|
1358
|
+
const { ERROR_TYPE_NAME: ERROR_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1359
|
+
const isEmpty = components.length === 0;
|
|
1360
|
+
const componentsTypeNames = components.map((componentUID) => {
|
|
1361
|
+
const component = strapi2.components[componentUID];
|
|
1362
|
+
if (!component) {
|
|
1363
|
+
throw new ApplicationError$1(
|
|
1364
|
+
`Trying to create a dynamic zone type with an unknown component: "${componentUID}"`
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
return component.globalId;
|
|
1368
|
+
});
|
|
1369
|
+
return nexus.unionType({
|
|
1370
|
+
name,
|
|
1371
|
+
resolveType(obj) {
|
|
1372
|
+
if (isEmpty) {
|
|
1373
|
+
return ERROR_TYPE_NAME2;
|
|
1374
|
+
}
|
|
1375
|
+
return strapi2.components[obj.__component].globalId;
|
|
1376
|
+
},
|
|
1377
|
+
definition(t) {
|
|
1378
|
+
t.members(...componentsTypeNames, ERROR_TYPE_NAME2);
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
};
|
|
1382
|
+
const buildInputDefinition = (name, components) => {
|
|
1383
|
+
const parseData = (value) => {
|
|
1384
|
+
const component = Object.values(strapi2.components).find(
|
|
1385
|
+
(component2) => component2.globalId === value.__typename
|
|
1386
|
+
);
|
|
1387
|
+
if (!component) {
|
|
1388
|
+
throw new ApplicationError$1(
|
|
1389
|
+
`Component not found. expected one of: ${components.map((uid) => strapi2.components[uid].globalId).join(", ")}`
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
return {
|
|
1393
|
+
__component: component.uid,
|
|
1394
|
+
...fp.omit(["__typename"], value)
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
return nexus.scalarType({
|
|
1398
|
+
name,
|
|
1399
|
+
serialize: (value) => value,
|
|
1400
|
+
parseValue: (value) => parseData(value),
|
|
1401
|
+
parseLiteral(ast, variables) {
|
|
1402
|
+
if (ast.kind !== graphql.Kind.OBJECT) {
|
|
1403
|
+
return void 0;
|
|
1404
|
+
}
|
|
1405
|
+
const value = graphql.valueFromASTUntyped(ast, variables);
|
|
1406
|
+
return parseData(value);
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
};
|
|
1410
|
+
return {
|
|
1411
|
+
/**
|
|
1412
|
+
* Build a Nexus dynamic zone type from a Strapi dz attribute
|
|
1413
|
+
* @param {object} definition - The definition of the dynamic zone
|
|
1414
|
+
* @param {string} name - the name of the dynamic zone
|
|
1415
|
+
* @param {string} inputName - the name of the dynamic zone's input
|
|
1416
|
+
* @return {[NexusUnionTypeDef, NexusScalarTypeDef]}
|
|
1417
|
+
*/
|
|
1418
|
+
buildDynamicZoneDefinition(definition, name, inputName) {
|
|
1419
|
+
const { components } = definition;
|
|
1420
|
+
const typeDefinition = buildTypeDefinition(name, components);
|
|
1421
|
+
const inputDefinition = buildInputDefinition(inputName, components);
|
|
1422
|
+
return [typeDefinition, inputDefinition];
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
const entity = ({ strapi: strapi2 }) => {
|
|
1427
|
+
const { naming: naming2 } = strapi2.plugin("graphql").service("utils");
|
|
1428
|
+
return {
|
|
1429
|
+
/**
|
|
1430
|
+
* Build a higher level type for a content type which contains the attributes, the ID and the metadata
|
|
1431
|
+
* @param {object} contentType The content type which will be used to build its entity type
|
|
1432
|
+
* @return {NexusObjectTypeDef}
|
|
1433
|
+
*/
|
|
1434
|
+
buildEntityDefinition(contentType2) {
|
|
1435
|
+
const { attributes: attributes2 } = contentType2;
|
|
1436
|
+
const name = naming2.getEntityName(contentType2);
|
|
1437
|
+
const typeName = naming2.getTypeName(contentType2);
|
|
1438
|
+
return nexus.objectType({
|
|
1439
|
+
name,
|
|
1440
|
+
definition(t) {
|
|
1441
|
+
t.id("id", { resolve: fp.prop("id") });
|
|
1442
|
+
if (!fp.isEmpty(attributes2)) {
|
|
1443
|
+
t.field("attributes", {
|
|
1444
|
+
type: typeName,
|
|
1445
|
+
resolve: fp.identity
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
};
|
|
1453
|
+
function buildEntityMetaDefinition() {
|
|
1454
|
+
}
|
|
1455
|
+
const entityMeta = () => ({
|
|
1456
|
+
buildEntityMetaDefinition
|
|
1457
|
+
});
|
|
1458
|
+
const typeBuilder = (context) => {
|
|
1459
|
+
const { strapi: strapi2 } = context;
|
|
1460
|
+
const getGraphQLService = strapi2.plugin("graphql").service;
|
|
1461
|
+
const extension = getGraphQLService("extension");
|
|
1462
|
+
const addScalarAttribute = (options) => {
|
|
1463
|
+
const { builder, attributeName, attribute } = options;
|
|
1464
|
+
const { mappers: mappers2 } = getGraphQLService("utils");
|
|
1465
|
+
const gqlType = mappers2.strapiScalarToGraphQLScalar(attribute.type);
|
|
1466
|
+
builder.field(attributeName, { type: gqlType });
|
|
1467
|
+
};
|
|
1468
|
+
const addComponentAttribute = (options) => {
|
|
1469
|
+
const { builder, attributeName, contentType: contentType2, attribute } = options;
|
|
1470
|
+
let localBuilder = builder;
|
|
1471
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1472
|
+
const { getContentTypeArgs } = getGraphQLService("builders").utils;
|
|
1473
|
+
const { buildComponentResolver } = getGraphQLService("builders").get("content-api");
|
|
1474
|
+
const type = naming2.getComponentNameFromAttribute(attribute);
|
|
1475
|
+
if (attribute.repeatable) {
|
|
1476
|
+
localBuilder = localBuilder.list;
|
|
1477
|
+
}
|
|
1478
|
+
const targetComponent = strapi2.getModel(attribute.component);
|
|
1479
|
+
const resolve = buildComponentResolver({
|
|
1480
|
+
contentTypeUID: contentType2.uid,
|
|
1481
|
+
attributeName,
|
|
1482
|
+
strapi: strapi2
|
|
1483
|
+
});
|
|
1484
|
+
const args2 = getContentTypeArgs(targetComponent, { multiple: !!attribute.repeatable });
|
|
1485
|
+
localBuilder.field(attributeName, { type, resolve, args: args2 });
|
|
1486
|
+
};
|
|
1487
|
+
const addDynamicZoneAttribute = (options) => {
|
|
1488
|
+
const { builder, attributeName, contentType: contentType2 } = options;
|
|
1489
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1490
|
+
const { ERROR_CODES: ERROR_CODES2 } = getGraphQLService("constants");
|
|
1491
|
+
const { buildDynamicZoneResolver } = getGraphQLService("builders").get("content-api");
|
|
1492
|
+
const { components } = contentType2.attributes[attributeName];
|
|
1493
|
+
const isEmpty = components.length === 0;
|
|
1494
|
+
const type = naming2.getDynamicZoneName(contentType2, attributeName);
|
|
1495
|
+
const resolve = isEmpty ? (
|
|
1496
|
+
// If the dynamic zone don't have any component, then return an error payload
|
|
1497
|
+
fp.constant({
|
|
1498
|
+
code: ERROR_CODES2.emptyDynamicZone,
|
|
1499
|
+
message: `This dynamic zone don't have any component attached to it`
|
|
1500
|
+
})
|
|
1501
|
+
) : (
|
|
1502
|
+
// Else, return a classic dynamic-zone resolver
|
|
1503
|
+
buildDynamicZoneResolver({
|
|
1504
|
+
contentTypeUID: contentType2.uid,
|
|
1505
|
+
attributeName
|
|
1506
|
+
})
|
|
1507
|
+
);
|
|
1508
|
+
builder.list.field(attributeName, { type, resolve });
|
|
1509
|
+
};
|
|
1510
|
+
const addEnumAttribute = (options) => {
|
|
1511
|
+
const { builder, attributeName, contentType: contentType2 } = options;
|
|
1512
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1513
|
+
const type = naming2.getEnumName(contentType2, attributeName);
|
|
1514
|
+
builder.field(attributeName, { type });
|
|
1515
|
+
};
|
|
1516
|
+
const addMediaAttribute = (options) => {
|
|
1517
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1518
|
+
const { getContentTypeArgs } = getGraphQLService("builders").utils;
|
|
1519
|
+
const { buildAssociationResolver } = getGraphQLService("builders").get("content-api");
|
|
1520
|
+
const extension2 = getGraphQLService("extension");
|
|
1521
|
+
const { builder } = options;
|
|
1522
|
+
const { attributeName, attribute, contentType: contentType2 } = options;
|
|
1523
|
+
const fileUID = "plugin::upload.file";
|
|
1524
|
+
if (extension2.shadowCRUD(fileUID).isDisabled()) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
const fileContentType = strapi2.contentTypes[fileUID];
|
|
1528
|
+
const resolve = buildAssociationResolver({
|
|
1529
|
+
contentTypeUID: contentType2.uid,
|
|
1530
|
+
attributeName,
|
|
1531
|
+
strapi: strapi2
|
|
1532
|
+
});
|
|
1533
|
+
const args2 = attribute.multiple ? getContentTypeArgs(fileContentType) : void 0;
|
|
1534
|
+
const type = attribute.multiple ? naming2.getRelationResponseCollectionName(fileContentType) : naming2.getEntityResponseName(fileContentType);
|
|
1535
|
+
builder.field(attributeName, { type, resolve, args: args2 });
|
|
1536
|
+
};
|
|
1537
|
+
const addPolymorphicRelationalAttribute = (options) => {
|
|
1538
|
+
const { GENERIC_MORPH_TYPENAME: GENERIC_MORPH_TYPENAME2 } = getGraphQLService("constants");
|
|
1539
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1540
|
+
const { buildAssociationResolver } = getGraphQLService("builders").get("content-api");
|
|
1541
|
+
let { builder } = options;
|
|
1542
|
+
const { attributeName, attribute, contentType: contentType2 } = options;
|
|
1543
|
+
const { target } = attribute;
|
|
1544
|
+
const isToManyRelation = attribute.relation.endsWith("Many");
|
|
1545
|
+
if (isToManyRelation) {
|
|
1546
|
+
builder = builder.list;
|
|
1547
|
+
}
|
|
1548
|
+
const resolve = buildAssociationResolver({
|
|
1549
|
+
contentTypeUID: contentType2.uid,
|
|
1550
|
+
attributeName,
|
|
1551
|
+
strapi: strapi2
|
|
1552
|
+
});
|
|
1553
|
+
if (fp.isUndefined(target)) {
|
|
1554
|
+
builder.field(attributeName, {
|
|
1555
|
+
type: GENERIC_MORPH_TYPENAME2,
|
|
1556
|
+
resolve
|
|
1557
|
+
});
|
|
1558
|
+
} else if (fp.isArray(target) && target.every(fp.isString)) {
|
|
1559
|
+
const type = naming2.getMorphRelationTypeName(contentType2, attributeName);
|
|
1560
|
+
builder.field(attributeName, { type, resolve });
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
const addRegularRelationalAttribute = (options) => {
|
|
1564
|
+
const { naming: naming2 } = getGraphQLService("utils");
|
|
1565
|
+
const { getContentTypeArgs } = getGraphQLService("builders").utils;
|
|
1566
|
+
const { buildAssociationResolver } = getGraphQLService("builders").get("content-api");
|
|
1567
|
+
const extension2 = getGraphQLService("extension");
|
|
1568
|
+
const { builder } = options;
|
|
1569
|
+
const { attributeName, attribute, contentType: contentType2 } = options;
|
|
1570
|
+
if (extension2.shadowCRUD(attribute.target).isDisabled()) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
const isToManyRelation = attribute.relation.endsWith("Many");
|
|
1574
|
+
const resolve = buildAssociationResolver({
|
|
1575
|
+
contentTypeUID: contentType2.uid,
|
|
1576
|
+
attributeName,
|
|
1577
|
+
strapi: strapi2
|
|
1578
|
+
});
|
|
1579
|
+
const targetContentType = strapi2.getModel(attribute.target);
|
|
1580
|
+
const type = isToManyRelation ? naming2.getRelationResponseCollectionName(targetContentType) : naming2.getEntityResponseName(targetContentType);
|
|
1581
|
+
const args2 = isToManyRelation ? getContentTypeArgs(targetContentType) : void 0;
|
|
1582
|
+
const resolverPath = `${naming2.getTypeName(contentType2)}.${attributeName}`;
|
|
1583
|
+
const resolverScope = `${targetContentType.uid}.find`;
|
|
1584
|
+
extension2.use({ resolversConfig: { [resolverPath]: { auth: { scope: [resolverScope] } } } });
|
|
1585
|
+
builder.field(attributeName, { type, resolve, args: args2 });
|
|
1586
|
+
};
|
|
1587
|
+
const isNotPrivate = (contentType2) => (attributeName) => {
|
|
1588
|
+
return !utils$2.contentTypes.isPrivateAttribute(contentType2, attributeName);
|
|
1589
|
+
};
|
|
1590
|
+
const isNotDisabled = (contentType2) => (attributeName) => {
|
|
1591
|
+
return extension.shadowCRUD(contentType2.uid).field(attributeName).hasOutputEnabled();
|
|
1592
|
+
};
|
|
1593
|
+
return {
|
|
1594
|
+
/**
|
|
1595
|
+
* Create a type definition for a given content type
|
|
1596
|
+
* @param contentType - The content type used to created the definition
|
|
1597
|
+
* @return {NexusObjectTypeDef}
|
|
1598
|
+
*/
|
|
1599
|
+
buildTypeDefinition(contentType2) {
|
|
1600
|
+
const utils2 = getGraphQLService("utils");
|
|
1601
|
+
const { getComponentName, getTypeName } = utils2.naming;
|
|
1602
|
+
const {
|
|
1603
|
+
isStrapiScalar,
|
|
1604
|
+
isComponent,
|
|
1605
|
+
isDynamicZone,
|
|
1606
|
+
isEnumeration,
|
|
1607
|
+
isMedia,
|
|
1608
|
+
isMorphRelation,
|
|
1609
|
+
isRelation
|
|
1610
|
+
} = utils2.attributes;
|
|
1611
|
+
const { attributes: attributes2, modelType } = contentType2;
|
|
1612
|
+
const attributesKey = Object.keys(attributes2);
|
|
1613
|
+
const name = (modelType === "component" ? getComponentName : getTypeName).call(
|
|
1614
|
+
null,
|
|
1615
|
+
contentType2
|
|
1616
|
+
);
|
|
1617
|
+
return nexus.objectType({
|
|
1618
|
+
name,
|
|
1619
|
+
definition(t) {
|
|
1620
|
+
if (modelType === "component" && isNotDisabled(contentType2)("id")) {
|
|
1621
|
+
t.nonNull.id("id");
|
|
1622
|
+
}
|
|
1623
|
+
attributesKey.filter(isNotPrivate(contentType2)).filter(isNotDisabled(contentType2)).forEach((attributeName) => {
|
|
1624
|
+
const attribute = attributes2[attributeName];
|
|
1625
|
+
let builder = t;
|
|
1626
|
+
if (attribute.required) {
|
|
1627
|
+
builder = builder.nonNull;
|
|
1628
|
+
}
|
|
1629
|
+
const options = {
|
|
1630
|
+
builder,
|
|
1631
|
+
attributeName,
|
|
1632
|
+
attribute,
|
|
1633
|
+
contentType: contentType2,
|
|
1634
|
+
context
|
|
1635
|
+
};
|
|
1636
|
+
if (isEnumeration(attribute)) {
|
|
1637
|
+
addEnumAttribute(options);
|
|
1638
|
+
} else if (isStrapiScalar(attribute)) {
|
|
1639
|
+
addScalarAttribute(options);
|
|
1640
|
+
} else if (isComponent(attribute)) {
|
|
1641
|
+
addComponentAttribute(options);
|
|
1642
|
+
} else if (isDynamicZone(attribute)) {
|
|
1643
|
+
addDynamicZoneAttribute(options);
|
|
1644
|
+
} else if (isMedia(attribute)) {
|
|
1645
|
+
addMediaAttribute(options);
|
|
1646
|
+
} else if (isMorphRelation(attribute)) {
|
|
1647
|
+
addPolymorphicRelationalAttribute(options);
|
|
1648
|
+
} else if (isRelation(attribute)) {
|
|
1649
|
+
addRegularRelationalAttribute(options);
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
const response = ({ strapi: strapi2 }) => {
|
|
1658
|
+
const { naming: naming2 } = strapi2.plugin("graphql").service("utils");
|
|
1659
|
+
return {
|
|
1660
|
+
/**
|
|
1661
|
+
* Build a type definition for a content API response for a given content type
|
|
1662
|
+
*/
|
|
1663
|
+
buildResponseDefinition(contentType2) {
|
|
1664
|
+
const name = naming2.getEntityResponseName(contentType2);
|
|
1665
|
+
const entityName = naming2.getEntityName(contentType2);
|
|
1666
|
+
return nexus.objectType({
|
|
1667
|
+
name,
|
|
1668
|
+
definition(t) {
|
|
1669
|
+
t.field("data", {
|
|
1670
|
+
type: entityName,
|
|
1671
|
+
resolve: fp.prop("value")
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
};
|
|
1678
|
+
const responseCollection = ({ strapi: strapi2 }) => {
|
|
1679
|
+
const { naming: naming2 } = strapi2.plugin("graphql").service("utils");
|
|
1680
|
+
const { RESPONSE_COLLECTION_META_TYPE_NAME: RESPONSE_COLLECTION_META_TYPE_NAME2 } = strapi2.plugin("graphql").service("constants");
|
|
1681
|
+
return {
|
|
1682
|
+
/**
|
|
1683
|
+
* Build a type definition for a content API collection response for a given content type
|
|
1684
|
+
* @param {Schema.ContentType} contentType The content type which will be used to build its content API response definition
|
|
1685
|
+
* @return {NexusObjectTypeDef}
|
|
1686
|
+
*/
|
|
1687
|
+
buildResponseCollectionDefinition(contentType2) {
|
|
1688
|
+
const name = naming2.getEntityResponseCollectionName(contentType2);
|
|
1689
|
+
const entityName = naming2.getEntityName(contentType2);
|
|
1690
|
+
return nexus.objectType({
|
|
1691
|
+
name,
|
|
1692
|
+
definition(t) {
|
|
1693
|
+
t.nonNull.list.field("data", {
|
|
1694
|
+
type: nexus.nonNull(entityName),
|
|
1695
|
+
resolve: fp.pipe(fp.prop("nodes"), fp.defaultTo([]))
|
|
1696
|
+
});
|
|
1697
|
+
t.nonNull.field("meta", {
|
|
1698
|
+
type: RESPONSE_COLLECTION_META_TYPE_NAME2,
|
|
1699
|
+
// Pass down the args stored in the source object
|
|
1700
|
+
resolve: fp.prop("info")
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
};
|
|
1707
|
+
const relationResponseCollection = ({ strapi: strapi2 }) => {
|
|
1708
|
+
const { naming: naming2 } = strapi2.plugin("graphql").service("utils");
|
|
1709
|
+
return {
|
|
1710
|
+
/**
|
|
1711
|
+
* Build a type definition for a content API relation's collection response for a given content type
|
|
1712
|
+
*/
|
|
1713
|
+
buildRelationResponseCollectionDefinition(contentType2) {
|
|
1714
|
+
const name = naming2.getRelationResponseCollectionName(contentType2);
|
|
1715
|
+
const entityName = naming2.getEntityName(contentType2);
|
|
1716
|
+
return nexus.objectType({
|
|
1717
|
+
name,
|
|
1718
|
+
definition(t) {
|
|
1719
|
+
t.nonNull.list.field("data", {
|
|
1720
|
+
type: nexus.nonNull(entityName),
|
|
1721
|
+
resolve: fp.pipe(fp.prop("nodes"), fp.defaultTo([]))
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
};
|
|
1728
|
+
const createCollectionTypeQueriesBuilder = ({ strapi: strapi2 }) => {
|
|
1729
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
1730
|
+
const { naming: naming2 } = getService("utils");
|
|
1731
|
+
const { transformArgs, getContentTypeArgs } = getService("builders").utils;
|
|
1732
|
+
const { toEntityResponse, toEntityResponseCollection } = getService("format").returnTypes;
|
|
1733
|
+
const {
|
|
1734
|
+
getFindOneQueryName,
|
|
1735
|
+
getEntityResponseName,
|
|
1736
|
+
getFindQueryName,
|
|
1737
|
+
getEntityResponseCollectionName
|
|
1738
|
+
} = naming2;
|
|
1739
|
+
const buildCollectionTypeQueries = (contentType2) => {
|
|
1740
|
+
const findOneQueryName = `Query.${getFindOneQueryName(contentType2)}`;
|
|
1741
|
+
const findQueryName = `Query.${getFindQueryName(contentType2)}`;
|
|
1742
|
+
const extension = getService("extension");
|
|
1743
|
+
const registerAuthConfig = (action, auth) => {
|
|
1744
|
+
return extension.use({ resolversConfig: { [action]: { auth } } });
|
|
1745
|
+
};
|
|
1746
|
+
const isActionEnabled = (action) => {
|
|
1747
|
+
return extension.shadowCRUD(contentType2.uid).isActionEnabled(action);
|
|
1748
|
+
};
|
|
1749
|
+
const isFindOneEnabled = isActionEnabled("findOne");
|
|
1750
|
+
const isFindEnabled = isActionEnabled("find");
|
|
1751
|
+
if (isFindOneEnabled) {
|
|
1752
|
+
registerAuthConfig(findOneQueryName, { scope: [`${contentType2.uid}.findOne`] });
|
|
1753
|
+
}
|
|
1754
|
+
if (isFindEnabled) {
|
|
1755
|
+
registerAuthConfig(findQueryName, { scope: [`${contentType2.uid}.find`] });
|
|
1756
|
+
}
|
|
1757
|
+
return nexus.extendType({
|
|
1758
|
+
type: "Query",
|
|
1759
|
+
definition(t) {
|
|
1760
|
+
if (isFindOneEnabled) {
|
|
1761
|
+
addFindOneQuery(t, contentType2);
|
|
1762
|
+
}
|
|
1763
|
+
if (isFindEnabled) {
|
|
1764
|
+
addFindQuery(t, contentType2);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
};
|
|
1769
|
+
const addFindOneQuery = (t, contentType2) => {
|
|
1770
|
+
const { uid } = contentType2;
|
|
1771
|
+
const findOneQueryName = getFindOneQueryName(contentType2);
|
|
1772
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1773
|
+
t.field(findOneQueryName, {
|
|
1774
|
+
type: responseTypeName,
|
|
1775
|
+
args: getContentTypeArgs(contentType2, { multiple: false }),
|
|
1776
|
+
async resolve(parent, args2, ctx) {
|
|
1777
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
1778
|
+
const { findOne } = getService("builders").get("content-api").buildQueriesResolvers({ contentType: contentType2 });
|
|
1779
|
+
const value = findOne(parent, transformedArgs, ctx);
|
|
1780
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
};
|
|
1784
|
+
const addFindQuery = (t, contentType2) => {
|
|
1785
|
+
const { uid } = contentType2;
|
|
1786
|
+
const findQueryName = getFindQueryName(contentType2);
|
|
1787
|
+
const responseCollectionTypeName = getEntityResponseCollectionName(contentType2);
|
|
1788
|
+
t.field(findQueryName, {
|
|
1789
|
+
type: responseCollectionTypeName,
|
|
1790
|
+
args: getContentTypeArgs(contentType2),
|
|
1791
|
+
async resolve(parent, args2, ctx) {
|
|
1792
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2, usePagination: true });
|
|
1793
|
+
const { find } = getService("builders").get("content-api").buildQueriesResolvers({ contentType: contentType2 });
|
|
1794
|
+
const nodes = await find(parent, transformedArgs, ctx);
|
|
1795
|
+
return toEntityResponseCollection(nodes, { args: transformedArgs, resourceUID: uid });
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
};
|
|
1799
|
+
return { buildCollectionTypeQueries };
|
|
1800
|
+
};
|
|
1801
|
+
const createSingleTypeQueriesBuilder = ({ strapi: strapi2 }) => {
|
|
1802
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
1803
|
+
const { naming: naming2 } = getService("utils");
|
|
1804
|
+
const { transformArgs, getContentTypeArgs } = getService("builders").utils;
|
|
1805
|
+
const { toEntityResponse } = getService("format").returnTypes;
|
|
1806
|
+
const { getFindOneQueryName, getEntityResponseName } = naming2;
|
|
1807
|
+
const buildSingleTypeQueries = (contentType2) => {
|
|
1808
|
+
const findQueryName = `Query.${getFindOneQueryName(contentType2)}`;
|
|
1809
|
+
const extension = getService("extension");
|
|
1810
|
+
const registerAuthConfig = (action, auth) => {
|
|
1811
|
+
return extension.use({ resolversConfig: { [action]: { auth } } });
|
|
1812
|
+
};
|
|
1813
|
+
const isActionEnabled = (action) => {
|
|
1814
|
+
return extension.shadowCRUD(contentType2.uid).isActionEnabled(action);
|
|
1815
|
+
};
|
|
1816
|
+
const isFindEnabled = isActionEnabled("find");
|
|
1817
|
+
if (isFindEnabled) {
|
|
1818
|
+
registerAuthConfig(findQueryName, { scope: [`${contentType2.uid}.find`] });
|
|
1819
|
+
}
|
|
1820
|
+
return nexus.extendType({
|
|
1821
|
+
type: "Query",
|
|
1822
|
+
definition(t) {
|
|
1823
|
+
if (isFindEnabled) {
|
|
1824
|
+
addFindQuery(t, contentType2);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
};
|
|
1829
|
+
const addFindQuery = (t, contentType2) => {
|
|
1830
|
+
const { uid } = contentType2;
|
|
1831
|
+
const findQueryName = getFindOneQueryName(contentType2);
|
|
1832
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1833
|
+
t.field(findQueryName, {
|
|
1834
|
+
type: responseTypeName,
|
|
1835
|
+
args: getContentTypeArgs(contentType2),
|
|
1836
|
+
async resolve(parent, args2, ctx) {
|
|
1837
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
1838
|
+
const queriesResolvers2 = getService("builders").get("content-api").buildQueriesResolvers({ contentType: contentType2 });
|
|
1839
|
+
const value = queriesResolvers2.find(parent, transformedArgs, ctx);
|
|
1840
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
};
|
|
1844
|
+
return { buildSingleTypeQueries };
|
|
1845
|
+
};
|
|
1846
|
+
const queries = (context) => ({
|
|
1847
|
+
...createCollectionTypeQueriesBuilder(context),
|
|
1848
|
+
...createSingleTypeQueriesBuilder(context)
|
|
1849
|
+
});
|
|
1850
|
+
const createCollectionTypeMutationsBuilder = ({ strapi: strapi2 }) => {
|
|
1851
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
1852
|
+
const { naming: naming2 } = getService("utils");
|
|
1853
|
+
const { transformArgs } = getService("builders").utils;
|
|
1854
|
+
const { toEntityResponse } = getService("format").returnTypes;
|
|
1855
|
+
const {
|
|
1856
|
+
getCreateMutationTypeName,
|
|
1857
|
+
getUpdateMutationTypeName,
|
|
1858
|
+
getDeleteMutationTypeName,
|
|
1859
|
+
getEntityResponseName,
|
|
1860
|
+
getContentTypeInputName
|
|
1861
|
+
} = naming2;
|
|
1862
|
+
const addCreateMutation = (t, contentType2) => {
|
|
1863
|
+
const { uid } = contentType2;
|
|
1864
|
+
const createMutationName = getCreateMutationTypeName(contentType2);
|
|
1865
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1866
|
+
t.field(createMutationName, {
|
|
1867
|
+
type: responseTypeName,
|
|
1868
|
+
args: {
|
|
1869
|
+
// Create payload
|
|
1870
|
+
data: nexus.nonNull(getContentTypeInputName(contentType2))
|
|
1871
|
+
},
|
|
1872
|
+
async resolve(parent, args2, context) {
|
|
1873
|
+
const { auth } = context.state;
|
|
1874
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
1875
|
+
const sanitizedInputData = await utils$2.sanitize.contentAPI.input(
|
|
1876
|
+
transformedArgs.data,
|
|
1877
|
+
contentType2,
|
|
1878
|
+
{ auth }
|
|
1879
|
+
);
|
|
1880
|
+
Object.assign(transformedArgs, { data: sanitizedInputData });
|
|
1881
|
+
const { create } = getService("builders").get("content-api").buildMutationsResolvers({ contentType: contentType2 });
|
|
1882
|
+
const value = await create(parent, transformedArgs);
|
|
1883
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
};
|
|
1887
|
+
const addUpdateMutation = (t, contentType2) => {
|
|
1888
|
+
const { uid } = contentType2;
|
|
1889
|
+
const updateMutationName = getUpdateMutationTypeName(contentType2);
|
|
1890
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1891
|
+
t.field(updateMutationName, {
|
|
1892
|
+
type: responseTypeName,
|
|
1893
|
+
args: {
|
|
1894
|
+
// Query args
|
|
1895
|
+
id: nexus.nonNull("ID"),
|
|
1896
|
+
// todo[v4]: Don't allow to filter using every unique attributes for now
|
|
1897
|
+
// ...uniqueAttributes,
|
|
1898
|
+
// Update payload
|
|
1899
|
+
data: nexus.nonNull(getContentTypeInputName(contentType2))
|
|
1900
|
+
},
|
|
1901
|
+
async resolve(parent, args2, context) {
|
|
1902
|
+
const { auth } = context.state;
|
|
1903
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
1904
|
+
const sanitizedInputData = await utils$2.sanitize.contentAPI.input(
|
|
1905
|
+
transformedArgs.data,
|
|
1906
|
+
contentType2,
|
|
1907
|
+
{ auth }
|
|
1908
|
+
);
|
|
1909
|
+
Object.assign(transformedArgs, { data: sanitizedInputData });
|
|
1910
|
+
const { update } = getService("builders").get("content-api").buildMutationsResolvers({ contentType: contentType2 });
|
|
1911
|
+
const value = await update(parent, transformedArgs);
|
|
1912
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
};
|
|
1916
|
+
const addDeleteMutation = (t, contentType2) => {
|
|
1917
|
+
const { uid } = contentType2;
|
|
1918
|
+
const deleteMutationName = getDeleteMutationTypeName(contentType2);
|
|
1919
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1920
|
+
t.field(deleteMutationName, {
|
|
1921
|
+
type: responseTypeName,
|
|
1922
|
+
args: {
|
|
1923
|
+
// Query args
|
|
1924
|
+
id: nexus.nonNull("ID")
|
|
1925
|
+
// todo[v4]: Don't allow to filter using every unique attributes for now
|
|
1926
|
+
// ...uniqueAttributes,
|
|
1927
|
+
},
|
|
1928
|
+
async resolve(parent, args2, ctx) {
|
|
1929
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
1930
|
+
const { delete: deleteResolver } = getService("builders").get("content-api").buildMutationsResolvers({ contentType: contentType2 });
|
|
1931
|
+
const value = await deleteResolver(parent, args2, ctx);
|
|
1932
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
};
|
|
1936
|
+
return {
|
|
1937
|
+
buildCollectionTypeMutations(contentType2) {
|
|
1938
|
+
const createMutationName = `Mutation.${getCreateMutationTypeName(contentType2)}`;
|
|
1939
|
+
const updateMutationName = `Mutation.${getUpdateMutationTypeName(contentType2)}`;
|
|
1940
|
+
const deleteMutationName = `Mutation.${getDeleteMutationTypeName(contentType2)}`;
|
|
1941
|
+
const extension = getService("extension");
|
|
1942
|
+
const registerAuthConfig = (action, auth) => {
|
|
1943
|
+
return extension.use({ resolversConfig: { [action]: { auth } } });
|
|
1944
|
+
};
|
|
1945
|
+
const isActionEnabled = (action) => {
|
|
1946
|
+
return extension.shadowCRUD(contentType2.uid).isActionEnabled(action);
|
|
1947
|
+
};
|
|
1948
|
+
const isCreateEnabled = isActionEnabled("create");
|
|
1949
|
+
const isUpdateEnabled = isActionEnabled("update");
|
|
1950
|
+
const isDeleteEnabled = isActionEnabled("delete");
|
|
1951
|
+
if (isCreateEnabled) {
|
|
1952
|
+
registerAuthConfig(createMutationName, { scope: [`${contentType2.uid}.create`] });
|
|
1953
|
+
}
|
|
1954
|
+
if (isUpdateEnabled) {
|
|
1955
|
+
registerAuthConfig(updateMutationName, { scope: [`${contentType2.uid}.update`] });
|
|
1956
|
+
}
|
|
1957
|
+
if (isDeleteEnabled) {
|
|
1958
|
+
registerAuthConfig(deleteMutationName, { scope: [`${contentType2.uid}.delete`] });
|
|
1959
|
+
}
|
|
1960
|
+
return nexus.extendType({
|
|
1961
|
+
type: "Mutation",
|
|
1962
|
+
definition(t) {
|
|
1963
|
+
if (isCreateEnabled) {
|
|
1964
|
+
addCreateMutation(t, contentType2);
|
|
1965
|
+
}
|
|
1966
|
+
if (isUpdateEnabled) {
|
|
1967
|
+
addUpdateMutation(t, contentType2);
|
|
1968
|
+
}
|
|
1969
|
+
if (isDeleteEnabled) {
|
|
1970
|
+
addDeleteMutation(t, contentType2);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
};
|
|
1977
|
+
const { NotFoundError } = utils$2.errors;
|
|
1978
|
+
const createSingleTypeMutationsBuilder = ({ strapi: strapi2 }) => {
|
|
1979
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
1980
|
+
const { naming: naming2 } = getService("utils");
|
|
1981
|
+
const { transformArgs } = getService("builders").utils;
|
|
1982
|
+
const { toEntityResponse } = getService("format").returnTypes;
|
|
1983
|
+
const {
|
|
1984
|
+
getUpdateMutationTypeName,
|
|
1985
|
+
getEntityResponseName,
|
|
1986
|
+
getContentTypeInputName,
|
|
1987
|
+
getDeleteMutationTypeName
|
|
1988
|
+
} = naming2;
|
|
1989
|
+
const addUpdateMutation = (t, contentType2) => {
|
|
1990
|
+
const { uid } = contentType2;
|
|
1991
|
+
const updateMutationName = getUpdateMutationTypeName(contentType2);
|
|
1992
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
1993
|
+
t.field(updateMutationName, {
|
|
1994
|
+
type: responseTypeName,
|
|
1995
|
+
args: {
|
|
1996
|
+
// Update payload
|
|
1997
|
+
data: nexus.nonNull(getContentTypeInputName(contentType2))
|
|
1998
|
+
},
|
|
1999
|
+
async resolve(parent, args2, context) {
|
|
2000
|
+
const { auth } = context.state;
|
|
2001
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
2002
|
+
const sanitizedInputData = await utils$2.sanitize.contentAPI.input(
|
|
2003
|
+
transformedArgs.data,
|
|
2004
|
+
contentType2,
|
|
2005
|
+
{ auth }
|
|
2006
|
+
);
|
|
2007
|
+
Object.assign(transformedArgs, { data: sanitizedInputData });
|
|
2008
|
+
const { create, update } = getService("builders").get("content-api").buildMutationsResolvers({ contentType: contentType2 });
|
|
2009
|
+
await utils$2.validate.contentAPI.query(fp.omit(["data", "files"], transformedArgs), contentType2, {
|
|
2010
|
+
auth
|
|
2011
|
+
});
|
|
2012
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(
|
|
2013
|
+
fp.omit(["data", "files"], transformedArgs),
|
|
2014
|
+
contentType2,
|
|
2015
|
+
{
|
|
2016
|
+
auth
|
|
2017
|
+
}
|
|
2018
|
+
);
|
|
2019
|
+
const entity2 = await strapi2.entityService.findMany(uid, sanitizedQuery);
|
|
2020
|
+
const value = fp.isNil(entity2) ? create(parent, transformedArgs) : update(uid, { id: entity2.id, data: transformedArgs.data });
|
|
2021
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
};
|
|
2025
|
+
const addDeleteMutation = (t, contentType2) => {
|
|
2026
|
+
const { uid } = contentType2;
|
|
2027
|
+
const deleteMutationName = getDeleteMutationTypeName(contentType2);
|
|
2028
|
+
const responseTypeName = getEntityResponseName(contentType2);
|
|
2029
|
+
t.field(deleteMutationName, {
|
|
2030
|
+
type: responseTypeName,
|
|
2031
|
+
args: {},
|
|
2032
|
+
async resolve(parent, args2, ctx) {
|
|
2033
|
+
const transformedArgs = transformArgs(args2, { contentType: contentType2 });
|
|
2034
|
+
const { delete: deleteResolver } = getService("builders").get("content-api").buildMutationsResolvers({ contentType: contentType2 });
|
|
2035
|
+
await utils$2.validate.contentAPI.query(transformedArgs, contentType2, { auth: ctx?.state?.auth });
|
|
2036
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(transformedArgs, contentType2, {
|
|
2037
|
+
auth: ctx?.state?.auth
|
|
2038
|
+
});
|
|
2039
|
+
const entity2 = await strapi2.entityService.findMany(uid, sanitizedQuery);
|
|
2040
|
+
if (!entity2) {
|
|
2041
|
+
throw new NotFoundError("Entity not found");
|
|
2042
|
+
}
|
|
2043
|
+
const value = await deleteResolver(parent, { id: entity2.id, params: transformedArgs });
|
|
2044
|
+
return toEntityResponse(value, { args: transformedArgs, resourceUID: uid });
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
};
|
|
2048
|
+
return {
|
|
2049
|
+
buildSingleTypeMutations(contentType2) {
|
|
2050
|
+
const updateMutationName = `Mutation.${getUpdateMutationTypeName(contentType2)}`;
|
|
2051
|
+
const deleteMutationName = `Mutation.${getDeleteMutationTypeName(contentType2)}`;
|
|
2052
|
+
const extension = getService("extension");
|
|
2053
|
+
const registerAuthConfig = (action, auth) => {
|
|
2054
|
+
return extension.use({ resolversConfig: { [action]: { auth } } });
|
|
2055
|
+
};
|
|
2056
|
+
const isActionEnabled = (action) => {
|
|
2057
|
+
return extension.shadowCRUD(contentType2.uid).isActionEnabled(action);
|
|
2058
|
+
};
|
|
2059
|
+
const isUpdateEnabled = isActionEnabled("update");
|
|
2060
|
+
const isDeleteEnabled = isActionEnabled("delete");
|
|
2061
|
+
if (isUpdateEnabled) {
|
|
2062
|
+
registerAuthConfig(updateMutationName, { scope: [`${contentType2.uid}.update`] });
|
|
2063
|
+
}
|
|
2064
|
+
if (isDeleteEnabled) {
|
|
2065
|
+
registerAuthConfig(deleteMutationName, { scope: [`${contentType2.uid}.delete`] });
|
|
2066
|
+
}
|
|
2067
|
+
return nexus.extendType({
|
|
2068
|
+
type: "Mutation",
|
|
2069
|
+
definition(t) {
|
|
2070
|
+
if (isUpdateEnabled) {
|
|
2071
|
+
addUpdateMutation(t, contentType2);
|
|
2072
|
+
}
|
|
2073
|
+
if (isDeleteEnabled) {
|
|
2074
|
+
addDeleteMutation(t, contentType2);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
};
|
|
2081
|
+
const mutations = (context) => ({
|
|
2082
|
+
...createCollectionTypeMutationsBuilder(context),
|
|
2083
|
+
...createSingleTypeMutationsBuilder(context)
|
|
2084
|
+
});
|
|
2085
|
+
const contentType = ({ strapi: strapi2 }) => {
|
|
2086
|
+
const rootLevelOperators = () => {
|
|
2087
|
+
const { operators: operators2 } = strapi2.plugin("graphql").service("builders").filters;
|
|
2088
|
+
return [operators2.and, operators2.or, operators2.not];
|
|
2089
|
+
};
|
|
2090
|
+
const addScalarAttribute = (builder, attributeName, attribute) => {
|
|
2091
|
+
const { naming: naming2, mappers: mappers2 } = strapi2.plugin("graphql").service("utils");
|
|
2092
|
+
const gqlType = mappers2.strapiScalarToGraphQLScalar(attribute.type);
|
|
2093
|
+
builder.field(attributeName, { type: naming2.getScalarFilterInputTypeName(gqlType) });
|
|
2094
|
+
};
|
|
2095
|
+
const addRelationalAttribute = (builder, attributeName, attribute) => {
|
|
2096
|
+
const utils2 = strapi2.plugin("graphql").service("utils");
|
|
2097
|
+
const extension = strapi2.plugin("graphql").service("extension");
|
|
2098
|
+
const { getFiltersInputTypeName } = utils2.naming;
|
|
2099
|
+
const { isMorphRelation } = utils2.attributes;
|
|
2100
|
+
const model = "target" in attribute && strapi2.getModel(attribute.target);
|
|
2101
|
+
if (!model || isMorphRelation(attribute))
|
|
2102
|
+
return;
|
|
2103
|
+
if (extension.shadowCRUD(model.uid).isDisabled())
|
|
2104
|
+
return;
|
|
2105
|
+
builder.field(attributeName, { type: getFiltersInputTypeName(model) });
|
|
2106
|
+
};
|
|
2107
|
+
const addComponentAttribute = (builder, attributeName, attribute) => {
|
|
2108
|
+
const utils2 = strapi2.plugin("graphql").service("utils");
|
|
2109
|
+
const extension = strapi2.plugin("graphql").service("extension");
|
|
2110
|
+
const { getFiltersInputTypeName } = utils2.naming;
|
|
2111
|
+
const component = strapi2.getModel(attribute.component);
|
|
2112
|
+
if (!component)
|
|
2113
|
+
return;
|
|
2114
|
+
if (extension.shadowCRUD(component.uid).isDisabled())
|
|
2115
|
+
return;
|
|
2116
|
+
builder.field(attributeName, { type: getFiltersInputTypeName(component) });
|
|
2117
|
+
};
|
|
2118
|
+
const buildContentTypeFilters = (contentType2) => {
|
|
2119
|
+
const utils2 = strapi2.plugin("graphql").service("utils");
|
|
2120
|
+
const extension = strapi2.plugin("graphql").service("extension");
|
|
2121
|
+
const { getFiltersInputTypeName, getScalarFilterInputTypeName } = utils2.naming;
|
|
2122
|
+
const { isStrapiScalar, isRelation, isComponent } = utils2.attributes;
|
|
2123
|
+
const { attributes: attributes2 } = contentType2;
|
|
2124
|
+
const filtersTypeName = getFiltersInputTypeName(contentType2);
|
|
2125
|
+
return nexus.inputObjectType({
|
|
2126
|
+
name: filtersTypeName,
|
|
2127
|
+
definition(t) {
|
|
2128
|
+
const validAttributes = Object.entries(attributes2).filter(
|
|
2129
|
+
([attributeName]) => extension.shadowCRUD(contentType2.uid).field(attributeName).hasFiltersEnabeld()
|
|
2130
|
+
);
|
|
2131
|
+
const isIDFilterEnabled = extension.shadowCRUD(contentType2.uid).field("id").hasFiltersEnabeld();
|
|
2132
|
+
if (contentType2.kind === "collectionType" && isIDFilterEnabled) {
|
|
2133
|
+
t.field("id", { type: getScalarFilterInputTypeName("ID") });
|
|
2134
|
+
}
|
|
2135
|
+
for (const [attributeName, attribute] of validAttributes) {
|
|
2136
|
+
if (isStrapiScalar(attribute)) {
|
|
2137
|
+
addScalarAttribute(t, attributeName, attribute);
|
|
2138
|
+
} else if (isRelation(attribute)) {
|
|
2139
|
+
addRelationalAttribute(t, attributeName, attribute);
|
|
2140
|
+
} else if (isComponent(attribute)) {
|
|
2141
|
+
addComponentAttribute(t, attributeName, attribute);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
for (const operator of rootLevelOperators()) {
|
|
2145
|
+
operator.add(t, filtersTypeName);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
};
|
|
2150
|
+
return {
|
|
2151
|
+
buildContentTypeFilters
|
|
2152
|
+
};
|
|
2153
|
+
};
|
|
2154
|
+
const filters = (context) => ({
|
|
2155
|
+
...contentType(context)
|
|
2156
|
+
});
|
|
2157
|
+
const { isWritableAttribute } = utils$2.contentTypes;
|
|
2158
|
+
const inputs = ({ strapi: strapi2 }) => {
|
|
2159
|
+
const { naming: naming2, mappers: mappers2, attributes: attributes2 } = strapi2.plugin("graphql").service("utils");
|
|
2160
|
+
const extension = strapi2.plugin("graphql").service("extension");
|
|
2161
|
+
const { getComponentInputName, getContentTypeInputName, getEnumName, getDynamicZoneInputName } = naming2;
|
|
2162
|
+
const {
|
|
2163
|
+
isStrapiScalar,
|
|
2164
|
+
isRelation,
|
|
2165
|
+
isMorphRelation,
|
|
2166
|
+
isMedia,
|
|
2167
|
+
isEnumeration,
|
|
2168
|
+
isComponent,
|
|
2169
|
+
isDynamicZone
|
|
2170
|
+
} = attributes2;
|
|
2171
|
+
return {
|
|
2172
|
+
buildInputType(contentType2) {
|
|
2173
|
+
const { attributes: attributes22, modelType } = contentType2;
|
|
2174
|
+
const name = (modelType === "component" ? getComponentInputName : getContentTypeInputName).call(null, contentType2);
|
|
2175
|
+
return nexus.inputObjectType({
|
|
2176
|
+
name,
|
|
2177
|
+
definition(t) {
|
|
2178
|
+
const isFieldEnabled = (fieldName) => {
|
|
2179
|
+
return extension.shadowCRUD(contentType2.uid).field(fieldName).hasInputEnabled();
|
|
2180
|
+
};
|
|
2181
|
+
const validAttributes = Object.entries(attributes22).filter(([attributeName]) => {
|
|
2182
|
+
return isWritableAttribute(contentType2, attributeName) && isFieldEnabled(attributeName);
|
|
2183
|
+
});
|
|
2184
|
+
if (modelType === "component" && isFieldEnabled("id")) {
|
|
2185
|
+
t.id("id");
|
|
2186
|
+
}
|
|
2187
|
+
validAttributes.forEach(([attributeName, attribute]) => {
|
|
2188
|
+
if (isEnumeration(attribute)) {
|
|
2189
|
+
const enumTypeName = getEnumName(contentType2, attributeName);
|
|
2190
|
+
t.field(attributeName, { type: enumTypeName });
|
|
2191
|
+
} else if (isStrapiScalar(attribute)) {
|
|
2192
|
+
const gqlScalar = mappers2.strapiScalarToGraphQLScalar(attribute.type);
|
|
2193
|
+
t.field(attributeName, { type: gqlScalar });
|
|
2194
|
+
} else if (isMedia(attribute)) {
|
|
2195
|
+
const isMultiple = attribute.multiple === true;
|
|
2196
|
+
if (extension.shadowCRUD("plugin::upload.file").isDisabled()) {
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
if (isMultiple) {
|
|
2200
|
+
t.list.id(attributeName);
|
|
2201
|
+
} else {
|
|
2202
|
+
t.id(attributeName);
|
|
2203
|
+
}
|
|
2204
|
+
} else if (isRelation(attribute) && !isMorphRelation(attribute)) {
|
|
2205
|
+
if (extension.shadowCRUD(attribute.target).isDisabled()) {
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
const isToManyRelation = attribute.relation.endsWith("Many");
|
|
2209
|
+
if (isToManyRelation) {
|
|
2210
|
+
t.list.id(attributeName);
|
|
2211
|
+
} else {
|
|
2212
|
+
t.id(attributeName);
|
|
2213
|
+
}
|
|
2214
|
+
} else if (isComponent(attribute)) {
|
|
2215
|
+
const isRepeatable = attribute.repeatable === true;
|
|
2216
|
+
const component = strapi2.components[attribute.component];
|
|
2217
|
+
const componentInputType = getComponentInputName(component);
|
|
2218
|
+
if (isRepeatable) {
|
|
2219
|
+
t.list.field(attributeName, { type: componentInputType });
|
|
2220
|
+
} else {
|
|
2221
|
+
t.field(attributeName, { type: componentInputType });
|
|
2222
|
+
}
|
|
2223
|
+
} else if (isDynamicZone(attribute)) {
|
|
2224
|
+
const dzInputName = getDynamicZoneInputName(contentType2, attributeName);
|
|
2225
|
+
t.list.field(attributeName, { type: nexus.nonNull(dzInputName) });
|
|
2226
|
+
}
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
};
|
|
2233
|
+
const genericMorph = ({ strapi: strapi2, registry }) => {
|
|
2234
|
+
const { naming: naming2 } = strapi2.plugin("graphql").service("utils");
|
|
2235
|
+
const { KINDS: KINDS2, GENERIC_MORPH_TYPENAME: GENERIC_MORPH_TYPENAME2 } = strapi2.plugin("graphql").service("constants");
|
|
2236
|
+
return {
|
|
2237
|
+
buildGenericMorphDefinition() {
|
|
2238
|
+
return nexus.unionType({
|
|
2239
|
+
name: GENERIC_MORPH_TYPENAME2,
|
|
2240
|
+
resolveType(obj) {
|
|
2241
|
+
const contentType2 = strapi2.getModel(obj.__type);
|
|
2242
|
+
if (!contentType2) {
|
|
2243
|
+
return null;
|
|
2244
|
+
}
|
|
2245
|
+
if (contentType2.modelType === "component") {
|
|
2246
|
+
return naming2.getComponentName(contentType2);
|
|
2247
|
+
}
|
|
2248
|
+
return naming2.getTypeName(contentType2);
|
|
2249
|
+
},
|
|
2250
|
+
definition(t) {
|
|
2251
|
+
const members = registry.where(({ config: config2 }) => [KINDS2.type, KINDS2.component].includes(config2.kind)).map(fp.prop("name"));
|
|
2252
|
+
t.members(...members);
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
};
|
|
2258
|
+
const { ApplicationError } = utils$2.errors;
|
|
2259
|
+
const associationResolvers = ({ strapi: strapi2 }) => {
|
|
2260
|
+
const { service: getGraphQLService } = strapi2.plugin("graphql");
|
|
2261
|
+
const { isMorphRelation, isMedia } = getGraphQLService("utils").attributes;
|
|
2262
|
+
const { transformArgs } = getGraphQLService("builders").utils;
|
|
2263
|
+
const { toEntityResponse, toEntityResponseCollection } = getGraphQLService("format").returnTypes;
|
|
2264
|
+
return {
|
|
2265
|
+
buildAssociationResolver({
|
|
2266
|
+
contentTypeUID,
|
|
2267
|
+
attributeName
|
|
2268
|
+
}) {
|
|
2269
|
+
const contentType2 = strapi2.getModel(contentTypeUID);
|
|
2270
|
+
const attribute = contentType2.attributes[attributeName];
|
|
2271
|
+
if (!attribute) {
|
|
2272
|
+
throw new ApplicationError(
|
|
2273
|
+
`Failed to build an association resolver for ${contentTypeUID}::${attributeName}`
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
const isMediaAttribute = isMedia(attribute);
|
|
2277
|
+
const isMorphAttribute = isMorphRelation(attribute);
|
|
2278
|
+
const targetUID = isMediaAttribute ? "plugin::upload.file" : attribute.target;
|
|
2279
|
+
const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith("Many");
|
|
2280
|
+
const targetContentType = strapi2.getModel(targetUID);
|
|
2281
|
+
return async (parent, args2 = {}, context = {}) => {
|
|
2282
|
+
const { auth } = context.state;
|
|
2283
|
+
const transformedArgs = transformArgs(args2, {
|
|
2284
|
+
contentType: targetContentType,
|
|
2285
|
+
usePagination: true
|
|
2286
|
+
});
|
|
2287
|
+
await utils$2.validate.contentAPI.query(transformedArgs, targetContentType, {
|
|
2288
|
+
auth
|
|
2289
|
+
});
|
|
2290
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(transformedArgs, targetContentType, {
|
|
2291
|
+
auth
|
|
2292
|
+
});
|
|
2293
|
+
const data = await strapi2.entityService.load(
|
|
2294
|
+
contentTypeUID,
|
|
2295
|
+
parent,
|
|
2296
|
+
attributeName,
|
|
2297
|
+
sanitizedQuery
|
|
2298
|
+
);
|
|
2299
|
+
const info = {
|
|
2300
|
+
args: sanitizedQuery,
|
|
2301
|
+
resourceUID: targetUID
|
|
2302
|
+
};
|
|
2303
|
+
if (isMorphAttribute) {
|
|
2304
|
+
const wrapData = (dataToWrap) => ({ [attributeName]: dataToWrap });
|
|
2305
|
+
const sanitizeData = (dataToSanitize) => {
|
|
2306
|
+
return utils$2.sanitize.contentAPI.output(dataToSanitize, contentType2, { auth });
|
|
2307
|
+
};
|
|
2308
|
+
const unwrapData = fp.get(attributeName);
|
|
2309
|
+
const sanitizeMorphAttribute = utils$2.pipeAsync(wrapData, sanitizeData, unwrapData);
|
|
2310
|
+
return sanitizeMorphAttribute(data);
|
|
2311
|
+
}
|
|
2312
|
+
if (isToMany) {
|
|
2313
|
+
return toEntityResponseCollection(data, info);
|
|
2314
|
+
}
|
|
2315
|
+
return toEntityResponse(data, info);
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
};
|
|
2320
|
+
const queriesResolvers = ({ strapi: strapi2 }) => ({
|
|
2321
|
+
buildQueriesResolvers({ contentType: contentType2 }) {
|
|
2322
|
+
const { uid } = contentType2;
|
|
2323
|
+
return {
|
|
2324
|
+
async find(parent, args2, ctx) {
|
|
2325
|
+
await utils$2.validate.contentAPI.query(args2, contentType2, {
|
|
2326
|
+
auth: ctx?.state?.auth
|
|
2327
|
+
});
|
|
2328
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(args2, contentType2, {
|
|
2329
|
+
auth: ctx?.state?.auth
|
|
2330
|
+
});
|
|
2331
|
+
return strapi2.entityService.findMany(uid, sanitizedQuery);
|
|
2332
|
+
},
|
|
2333
|
+
async findOne(parent, args2, ctx) {
|
|
2334
|
+
await utils$2.validate.contentAPI.query(args2, contentType2, {
|
|
2335
|
+
auth: ctx?.state?.auth
|
|
2336
|
+
});
|
|
2337
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(args2, contentType2, {
|
|
2338
|
+
auth: ctx?.state?.auth
|
|
2339
|
+
});
|
|
2340
|
+
return strapi2.entityService.findOne(uid, args2.id, fp.omit("id", sanitizedQuery));
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
const pickCreateArgs = fp.pick(["params", "data", "files"]);
|
|
2346
|
+
const mutationsResolvers = ({ strapi: strapi2 }) => ({
|
|
2347
|
+
buildMutationsResolvers({ contentType: contentType2 }) {
|
|
2348
|
+
const { uid } = contentType2;
|
|
2349
|
+
return {
|
|
2350
|
+
async create(parent, args2) {
|
|
2351
|
+
const params = pickCreateArgs(args2);
|
|
2352
|
+
return strapi2.entityService.create(uid, params);
|
|
2353
|
+
},
|
|
2354
|
+
async update(parent, args2) {
|
|
2355
|
+
const { id, data } = args2;
|
|
2356
|
+
return strapi2.entityService.update(uid, id, { data });
|
|
2357
|
+
},
|
|
2358
|
+
async delete(parent, args2, ctx) {
|
|
2359
|
+
const { id, ...rest } = args2;
|
|
2360
|
+
await utils$2.validate.contentAPI.query(rest, contentType2, {
|
|
2361
|
+
auth: ctx?.state?.auth
|
|
2362
|
+
});
|
|
2363
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(rest, contentType2, {
|
|
2364
|
+
auth: ctx?.state?.auth
|
|
2365
|
+
});
|
|
2366
|
+
return strapi2.entityService.delete(uid, id, sanitizedQuery);
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
});
|
|
2371
|
+
const componentResolvers = ({ strapi: strapi2 }) => ({
|
|
2372
|
+
buildComponentResolver({
|
|
2373
|
+
contentTypeUID,
|
|
2374
|
+
attributeName
|
|
2375
|
+
}) {
|
|
2376
|
+
const { transformArgs } = strapi2.plugin("graphql").service("builders").utils;
|
|
2377
|
+
return async (parent, args2, ctx) => {
|
|
2378
|
+
const contentType2 = strapi2.getModel(contentTypeUID);
|
|
2379
|
+
const { component: componentName } = contentType2.attributes[attributeName];
|
|
2380
|
+
const component = strapi2.getModel(componentName);
|
|
2381
|
+
const transformedArgs = transformArgs(args2, { contentType: component, usePagination: true });
|
|
2382
|
+
await utils$2.validate.contentAPI.query(transformedArgs, component, {
|
|
2383
|
+
auth: ctx?.state?.auth
|
|
2384
|
+
});
|
|
2385
|
+
const sanitizedQuery = await utils$2.sanitize.contentAPI.query(transformedArgs, component, {
|
|
2386
|
+
auth: ctx?.state?.auth
|
|
2387
|
+
});
|
|
2388
|
+
return strapi2.entityService.load(contentTypeUID, parent, attributeName, sanitizedQuery);
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
});
|
|
2392
|
+
const dynamicZoneResolvers = ({ strapi: strapi2 }) => ({
|
|
2393
|
+
buildDynamicZoneResolver({
|
|
2394
|
+
contentTypeUID,
|
|
2395
|
+
attributeName
|
|
2396
|
+
}) {
|
|
2397
|
+
return async (parent) => {
|
|
2398
|
+
return strapi2.entityService.load(contentTypeUID, parent, attributeName);
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
const resolvers = (context) => ({
|
|
2403
|
+
// Generics
|
|
2404
|
+
...associationResolvers(context),
|
|
2405
|
+
// Builders
|
|
2406
|
+
...mutationsResolvers(context),
|
|
2407
|
+
...queriesResolvers(context),
|
|
2408
|
+
...componentResolvers(context),
|
|
2409
|
+
...dynamicZoneResolvers(context)
|
|
2410
|
+
});
|
|
2411
|
+
const AND_FIELD_NAME = "and";
|
|
2412
|
+
const andOperator = () => ({
|
|
2413
|
+
fieldName: AND_FIELD_NAME,
|
|
2414
|
+
strapiOperator: "$and",
|
|
2415
|
+
add(t, type) {
|
|
2416
|
+
t.field(AND_FIELD_NAME, { type: nexus.list(type) });
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
const OR_FIELD_NAME = "or";
|
|
2420
|
+
const orOperator = () => ({
|
|
2421
|
+
fieldName: OR_FIELD_NAME,
|
|
2422
|
+
strapiOperator: "$or",
|
|
2423
|
+
add(t, type) {
|
|
2424
|
+
t.field(OR_FIELD_NAME, { type: nexus.list(type) });
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
const NOT_FIELD_NAME = "not";
|
|
2428
|
+
const notOperator = ({ strapi: strapi2 }) => ({
|
|
2429
|
+
fieldName: NOT_FIELD_NAME,
|
|
2430
|
+
strapiOperator: "$not",
|
|
2431
|
+
add(t, type) {
|
|
2432
|
+
const { naming: naming2, attributes: attributes2 } = strapi2.plugin("graphql").service("utils");
|
|
2433
|
+
if (attributes2.isGraphQLScalar({ type })) {
|
|
2434
|
+
t.field(NOT_FIELD_NAME, { type: naming2.getScalarFilterInputTypeName(type) });
|
|
2435
|
+
} else {
|
|
2436
|
+
t.field(NOT_FIELD_NAME, { type });
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2440
|
+
const { ValidationError } = utils$2.errors;
|
|
2441
|
+
const EQ_FIELD_NAME = "eq";
|
|
2442
|
+
const eqOperator = ({ strapi: strapi2 }) => ({
|
|
2443
|
+
fieldName: EQ_FIELD_NAME,
|
|
2444
|
+
strapiOperator: "$eq",
|
|
2445
|
+
add(t, type) {
|
|
2446
|
+
const { GRAPHQL_SCALARS: GRAPHQL_SCALARS2 } = strapi2.plugin("graphql").service("constants");
|
|
2447
|
+
if (!GRAPHQL_SCALARS2.includes(type)) {
|
|
2448
|
+
throw new ValidationError(
|
|
2449
|
+
`Can't use "${EQ_FIELD_NAME}" operator. "${type}" is not a valid scalar`
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
t.field(EQ_FIELD_NAME, { type });
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2455
|
+
const EQI_FIELD_NAME = "eqi";
|
|
2456
|
+
const eqiOperator = () => ({
|
|
2457
|
+
fieldName: EQI_FIELD_NAME,
|
|
2458
|
+
strapiOperator: "$eqi",
|
|
2459
|
+
add(t, type) {
|
|
2460
|
+
t.field(EQI_FIELD_NAME, { type });
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
const NE_FIELD_NAME = "ne";
|
|
2464
|
+
const neOperator = () => ({
|
|
2465
|
+
fieldName: NE_FIELD_NAME,
|
|
2466
|
+
strapiOperator: "$ne",
|
|
2467
|
+
add(t, type) {
|
|
2468
|
+
t.field(NE_FIELD_NAME, { type });
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
const NEI_FIELD_NAME = "nei";
|
|
2472
|
+
const neiOperator = () => ({
|
|
2473
|
+
fieldName: NEI_FIELD_NAME,
|
|
2474
|
+
strapiOperator: "$nei",
|
|
2475
|
+
add(t, type) {
|
|
2476
|
+
t.field(NEI_FIELD_NAME, { type });
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2479
|
+
const STARTS_WITH_FIELD_NAME = "startsWith";
|
|
2480
|
+
const startsWithOperator = () => ({
|
|
2481
|
+
fieldName: STARTS_WITH_FIELD_NAME,
|
|
2482
|
+
strapiOperator: "$startsWith",
|
|
2483
|
+
add(t, type) {
|
|
2484
|
+
t.field(STARTS_WITH_FIELD_NAME, { type });
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
const ENDS_WITH_FIELD_NAME = "endsWith";
|
|
2488
|
+
const endsWithOperator = () => ({
|
|
2489
|
+
fieldName: ENDS_WITH_FIELD_NAME,
|
|
2490
|
+
strapiOperator: "$endsWith",
|
|
2491
|
+
add(t, type) {
|
|
2492
|
+
t.field(ENDS_WITH_FIELD_NAME, { type });
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
const CONTAINS_FIELD_NAME = "contains";
|
|
2496
|
+
const containsOperator = () => ({
|
|
2497
|
+
fieldName: CONTAINS_FIELD_NAME,
|
|
2498
|
+
strapiOperator: "$contains",
|
|
2499
|
+
add(t, type) {
|
|
2500
|
+
t.field(CONTAINS_FIELD_NAME, { type });
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
const NOT_CONTAINS_FIELD_NAME = "notContains";
|
|
2504
|
+
const notContainsOperator = () => ({
|
|
2505
|
+
fieldName: NOT_CONTAINS_FIELD_NAME,
|
|
2506
|
+
strapiOperator: "$notContains",
|
|
2507
|
+
add(t, type) {
|
|
2508
|
+
t.field(NOT_CONTAINS_FIELD_NAME, { type });
|
|
2509
|
+
}
|
|
2510
|
+
});
|
|
2511
|
+
const CONTAINSI_FIELD_NAME = "containsi";
|
|
2512
|
+
const containsiOperator = () => ({
|
|
2513
|
+
fieldName: CONTAINSI_FIELD_NAME,
|
|
2514
|
+
strapiOperator: "$containsi",
|
|
2515
|
+
add(t, type) {
|
|
2516
|
+
t.field(CONTAINSI_FIELD_NAME, { type });
|
|
2517
|
+
}
|
|
2518
|
+
});
|
|
2519
|
+
const NOT_CONTAINSI_FIELD_NAME = "notContainsi";
|
|
2520
|
+
const notContainsiOperator = () => ({
|
|
2521
|
+
fieldName: NOT_CONTAINSI_FIELD_NAME,
|
|
2522
|
+
strapiOperator: "$notContainsi",
|
|
2523
|
+
add(t, type) {
|
|
2524
|
+
t.field(NOT_CONTAINSI_FIELD_NAME, { type });
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
const GT_FIELD_NAME = "gt";
|
|
2528
|
+
const gtOperator = () => ({
|
|
2529
|
+
fieldName: GT_FIELD_NAME,
|
|
2530
|
+
strapiOperator: "$gt",
|
|
2531
|
+
add(t, type) {
|
|
2532
|
+
t.field(GT_FIELD_NAME, { type });
|
|
2533
|
+
}
|
|
2534
|
+
});
|
|
2535
|
+
const GTE_FIELD_NAME = "gte";
|
|
2536
|
+
const gteOperator = () => ({
|
|
2537
|
+
fieldName: GTE_FIELD_NAME,
|
|
2538
|
+
strapiOperator: "$gte",
|
|
2539
|
+
add(t, type) {
|
|
2540
|
+
t.field(GTE_FIELD_NAME, { type });
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
const LT_FIELD_NAME = "lt";
|
|
2544
|
+
const ltOperator = () => ({
|
|
2545
|
+
fieldName: LT_FIELD_NAME,
|
|
2546
|
+
strapiOperator: "$lt",
|
|
2547
|
+
add(t, type) {
|
|
2548
|
+
t.field(LT_FIELD_NAME, { type });
|
|
2549
|
+
}
|
|
2550
|
+
});
|
|
2551
|
+
const LTE_FIELD_NAME = "lte";
|
|
2552
|
+
const lteOperator = () => ({
|
|
2553
|
+
fieldName: LTE_FIELD_NAME,
|
|
2554
|
+
strapiOperator: "$lte",
|
|
2555
|
+
add(t, type) {
|
|
2556
|
+
t.field(LTE_FIELD_NAME, { type });
|
|
2557
|
+
}
|
|
2558
|
+
});
|
|
2559
|
+
const NULL_FIELD_NAME = "null";
|
|
2560
|
+
const nullOperator = () => ({
|
|
2561
|
+
fieldName: NULL_FIELD_NAME,
|
|
2562
|
+
strapiOperator: "$null",
|
|
2563
|
+
add(t) {
|
|
2564
|
+
t.boolean(NULL_FIELD_NAME);
|
|
2565
|
+
}
|
|
2566
|
+
});
|
|
2567
|
+
const NOT_NULL_FIELD_NAME = "notNull";
|
|
2568
|
+
const notNullOperator = () => ({
|
|
2569
|
+
fieldName: NOT_NULL_FIELD_NAME,
|
|
2570
|
+
strapiOperator: "$notNull",
|
|
2571
|
+
add(t) {
|
|
2572
|
+
t.boolean(NOT_NULL_FIELD_NAME);
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
const IN_FIELD_NAME = "in";
|
|
2576
|
+
const inOperator = () => ({
|
|
2577
|
+
fieldName: IN_FIELD_NAME,
|
|
2578
|
+
strapiOperator: "$in",
|
|
2579
|
+
add(t, type) {
|
|
2580
|
+
t.field(IN_FIELD_NAME, { type: nexus.list(type) });
|
|
2581
|
+
}
|
|
2582
|
+
});
|
|
2583
|
+
const NOT_IN_FIELD_NAME = "notIn";
|
|
2584
|
+
const notInOperator = () => ({
|
|
2585
|
+
fieldName: NOT_IN_FIELD_NAME,
|
|
2586
|
+
strapiOperator: "$notIn",
|
|
2587
|
+
add(t, type) {
|
|
2588
|
+
t.field(NOT_IN_FIELD_NAME, { type: nexus.list(type) });
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2591
|
+
const BETWEEN_FIELD_NAME = "between";
|
|
2592
|
+
const betweenOperator = () => ({
|
|
2593
|
+
fieldName: BETWEEN_FIELD_NAME,
|
|
2594
|
+
strapiOperator: "$between",
|
|
2595
|
+
add(t, type) {
|
|
2596
|
+
t.field(BETWEEN_FIELD_NAME, { type: nexus.list(type) });
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
const operators = {
|
|
2600
|
+
and: andOperator,
|
|
2601
|
+
or: orOperator,
|
|
2602
|
+
not: notOperator,
|
|
2603
|
+
eq: eqOperator,
|
|
2604
|
+
eqi: eqiOperator,
|
|
2605
|
+
ne: neOperator,
|
|
2606
|
+
nei: neiOperator,
|
|
2607
|
+
startsWith: startsWithOperator,
|
|
2608
|
+
endsWith: endsWithOperator,
|
|
2609
|
+
contains: containsOperator,
|
|
2610
|
+
notContains: notContainsOperator,
|
|
2611
|
+
containsi: containsiOperator,
|
|
2612
|
+
notContainsi: notContainsiOperator,
|
|
2613
|
+
gt: gtOperator,
|
|
2614
|
+
gte: gteOperator,
|
|
2615
|
+
lt: ltOperator,
|
|
2616
|
+
lte: lteOperator,
|
|
2617
|
+
null: nullOperator,
|
|
2618
|
+
notNull: notNullOperator,
|
|
2619
|
+
in: inOperator,
|
|
2620
|
+
notIn: notInOperator,
|
|
2621
|
+
between: betweenOperator
|
|
2622
|
+
};
|
|
2623
|
+
const operators$1 = ({ strapi: strapi2 }) => fp.mapValues((opCtor) => opCtor({ strapi: strapi2 }), operators);
|
|
2624
|
+
const { withDefaultPagination } = utils$2.pagination;
|
|
2625
|
+
const { hasDraftAndPublish } = utils$2.contentTypes;
|
|
2626
|
+
const utils = ({ strapi: strapi2 }) => {
|
|
2627
|
+
const { service: getService } = strapi2.plugin("graphql");
|
|
2628
|
+
return {
|
|
2629
|
+
/**
|
|
2630
|
+
* Get every args for a given content type
|
|
2631
|
+
* @param {object} contentType
|
|
2632
|
+
* @param {object} options
|
|
2633
|
+
* @param {boolean} options.multiple
|
|
2634
|
+
* @return {object}
|
|
2635
|
+
*/
|
|
2636
|
+
getContentTypeArgs(contentType2, { multiple = true } = {}) {
|
|
2637
|
+
const { naming: naming2 } = getService("utils");
|
|
2638
|
+
const { args: args2 } = getService("internals");
|
|
2639
|
+
const { modelType } = contentType2;
|
|
2640
|
+
if (modelType === "component") {
|
|
2641
|
+
if (!multiple)
|
|
2642
|
+
return {};
|
|
2643
|
+
return {
|
|
2644
|
+
filters: naming2.getFiltersInputTypeName(contentType2),
|
|
2645
|
+
pagination: args2.PaginationArg,
|
|
2646
|
+
sort: args2.SortArg
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
const { kind } = contentType2;
|
|
2650
|
+
if (kind === "collectionType") {
|
|
2651
|
+
if (!multiple) {
|
|
2652
|
+
return { id: "ID" };
|
|
2653
|
+
}
|
|
2654
|
+
const params = {
|
|
2655
|
+
filters: naming2.getFiltersInputTypeName(contentType2),
|
|
2656
|
+
pagination: args2.PaginationArg,
|
|
2657
|
+
sort: args2.SortArg
|
|
2658
|
+
};
|
|
2659
|
+
if (hasDraftAndPublish(contentType2)) {
|
|
2660
|
+
Object.assign(params, { publicationState: args2.PublicationStateArg });
|
|
2661
|
+
}
|
|
2662
|
+
return params;
|
|
2663
|
+
}
|
|
2664
|
+
if (kind === "singleType") {
|
|
2665
|
+
const params = {};
|
|
2666
|
+
if (hasDraftAndPublish(contentType2)) {
|
|
2667
|
+
Object.assign(params, { publicationState: args2.PublicationStateArg });
|
|
2668
|
+
}
|
|
2669
|
+
return params;
|
|
2670
|
+
}
|
|
2671
|
+
},
|
|
2672
|
+
/**
|
|
2673
|
+
* Filter an object entries and keep only those whose value is a unique scalar attribute
|
|
2674
|
+
*/
|
|
2675
|
+
getUniqueScalarAttributes(attributes2) {
|
|
2676
|
+
const { isStrapiScalar } = getService("utils").attributes;
|
|
2677
|
+
const uniqueAttributes = fp.entries(attributes2).filter(
|
|
2678
|
+
([, attribute]) => isStrapiScalar(attribute) && "unique" in attribute && attribute.unique
|
|
2679
|
+
);
|
|
2680
|
+
return Object.fromEntries(uniqueAttributes);
|
|
2681
|
+
},
|
|
2682
|
+
/**
|
|
2683
|
+
* Map each value from an attribute to a FiltersInput type name
|
|
2684
|
+
* @param {object} attributes - The attributes object to transform
|
|
2685
|
+
* @return {Object<string, string>}
|
|
2686
|
+
*/
|
|
2687
|
+
scalarAttributesToFiltersMap(attributes2) {
|
|
2688
|
+
return fp.mapValues((attribute) => {
|
|
2689
|
+
const { mappers: mappers2, naming: naming2 } = getService("utils");
|
|
2690
|
+
const gqlScalar = mappers2.strapiScalarToGraphQLScalar(attribute.type);
|
|
2691
|
+
return naming2.getScalarFilterInputTypeName(gqlScalar);
|
|
2692
|
+
}, attributes2);
|
|
2693
|
+
},
|
|
2694
|
+
/**
|
|
2695
|
+
* Apply basic transform to GQL args
|
|
2696
|
+
*/
|
|
2697
|
+
transformArgs(args2, {
|
|
2698
|
+
contentType: contentType2,
|
|
2699
|
+
usePagination = false
|
|
2700
|
+
}) {
|
|
2701
|
+
const { mappers: mappers2 } = getService("utils");
|
|
2702
|
+
const { config: config2 } = strapi2.plugin("graphql");
|
|
2703
|
+
const { pagination: pagination2 = {}, filters: filters2 = {} } = args2;
|
|
2704
|
+
const newArgs = fp.omit(["pagination", "filters"], args2);
|
|
2705
|
+
if (usePagination) {
|
|
2706
|
+
const defaultLimit = config2("defaultLimit");
|
|
2707
|
+
const maxLimit = config2("maxLimit");
|
|
2708
|
+
Object.assign(
|
|
2709
|
+
newArgs,
|
|
2710
|
+
withDefaultPagination(pagination2, {
|
|
2711
|
+
maxLimit,
|
|
2712
|
+
defaults: {
|
|
2713
|
+
offset: { limit: defaultLimit },
|
|
2714
|
+
page: { pageSize: defaultLimit }
|
|
2715
|
+
}
|
|
2716
|
+
})
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
if (args2.filters) {
|
|
2720
|
+
Object.assign(newArgs, {
|
|
2721
|
+
filters: mappers2.graphQLFiltersToStrapiQuery(filters2, contentType2)
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
return newArgs;
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
};
|
|
2728
|
+
const buildersFactories = [
|
|
2729
|
+
enums,
|
|
2730
|
+
dynamicZone,
|
|
2731
|
+
entity,
|
|
2732
|
+
entityMeta,
|
|
2733
|
+
typeBuilder,
|
|
2734
|
+
response,
|
|
2735
|
+
responseCollection,
|
|
2736
|
+
relationResponseCollection,
|
|
2737
|
+
queries,
|
|
2738
|
+
mutations,
|
|
2739
|
+
filters,
|
|
2740
|
+
inputs,
|
|
2741
|
+
genericMorph,
|
|
2742
|
+
resolvers
|
|
2743
|
+
];
|
|
2744
|
+
const builders = ({ strapi: strapi2 }) => {
|
|
2745
|
+
const buildersMap = /* @__PURE__ */ new Map();
|
|
2746
|
+
return {
|
|
2747
|
+
/**
|
|
2748
|
+
* Instantiate every builder with a strapi instance & a type registry
|
|
2749
|
+
*/
|
|
2750
|
+
new(name, registry) {
|
|
2751
|
+
const context = { strapi: strapi2, registry };
|
|
2752
|
+
const builders2 = fp.pipe(
|
|
2753
|
+
// Create a new instance of every builders
|
|
2754
|
+
fp.map((factory) => factory(context)),
|
|
2755
|
+
// Merge every builder into the same object
|
|
2756
|
+
fp.reduce(fp.merge, {})
|
|
2757
|
+
).call(null, buildersFactories);
|
|
2758
|
+
buildersMap.set(name, builders2);
|
|
2759
|
+
return builders2;
|
|
2760
|
+
},
|
|
2761
|
+
/**
|
|
2762
|
+
* Delete a set of builders instances from
|
|
2763
|
+
* the builders map for a given name
|
|
2764
|
+
*/
|
|
2765
|
+
delete(name) {
|
|
2766
|
+
buildersMap.delete(name);
|
|
2767
|
+
},
|
|
2768
|
+
/**
|
|
2769
|
+
* Retrieve a set of builders instances from
|
|
2770
|
+
* the builders map for a given name
|
|
2771
|
+
*/
|
|
2772
|
+
get(name) {
|
|
2773
|
+
return buildersMap.get(name);
|
|
2774
|
+
},
|
|
2775
|
+
filters: {
|
|
2776
|
+
operators: operators$1({ strapi: strapi2 })
|
|
2777
|
+
},
|
|
2778
|
+
utils: utils({ strapi: strapi2 })
|
|
2779
|
+
};
|
|
2780
|
+
};
|
|
2781
|
+
const getDefaultContentTypeConfig = () => ({
|
|
2782
|
+
enabled: true,
|
|
2783
|
+
mutations: true,
|
|
2784
|
+
queries: true,
|
|
2785
|
+
disabledActions: [],
|
|
2786
|
+
fields: /* @__PURE__ */ new Map()
|
|
2787
|
+
});
|
|
2788
|
+
const getDefaultFieldConfig = () => ({
|
|
2789
|
+
enabled: true,
|
|
2790
|
+
input: true,
|
|
2791
|
+
output: true,
|
|
2792
|
+
filters: true
|
|
2793
|
+
});
|
|
2794
|
+
const ALL_ACTIONS = "*";
|
|
2795
|
+
const createShadowCRUDManager = () => {
|
|
2796
|
+
const configs = /* @__PURE__ */ new Map();
|
|
2797
|
+
return (uid) => {
|
|
2798
|
+
if (!configs.has(uid)) {
|
|
2799
|
+
configs.set(uid, getDefaultContentTypeConfig());
|
|
2800
|
+
}
|
|
2801
|
+
return {
|
|
2802
|
+
isEnabled() {
|
|
2803
|
+
return configs.get(uid).enabled;
|
|
2804
|
+
},
|
|
2805
|
+
isDisabled() {
|
|
2806
|
+
return !this.isEnabled();
|
|
2807
|
+
},
|
|
2808
|
+
areQueriesEnabled() {
|
|
2809
|
+
return configs.get(uid).queries;
|
|
2810
|
+
},
|
|
2811
|
+
areQueriesDisabled() {
|
|
2812
|
+
return !this.areQueriesEnabled();
|
|
2813
|
+
},
|
|
2814
|
+
areMutationsEnabled() {
|
|
2815
|
+
return configs.get(uid).mutations;
|
|
2816
|
+
},
|
|
2817
|
+
areMutationsDisabled() {
|
|
2818
|
+
return !this.areMutationsEnabled();
|
|
2819
|
+
},
|
|
2820
|
+
isActionEnabled(action) {
|
|
2821
|
+
const matchingActions = [action, ALL_ACTIONS];
|
|
2822
|
+
return configs.get(uid).disabledActions.every((action2) => !matchingActions.includes(action2));
|
|
2823
|
+
},
|
|
2824
|
+
isActionDisabled(action) {
|
|
2825
|
+
return !this.isActionEnabled(action);
|
|
2826
|
+
},
|
|
2827
|
+
disable() {
|
|
2828
|
+
configs.get(uid).enabled = false;
|
|
2829
|
+
return this;
|
|
2830
|
+
},
|
|
2831
|
+
disableQueries() {
|
|
2832
|
+
configs.get(uid).queries = false;
|
|
2833
|
+
return this;
|
|
2834
|
+
},
|
|
2835
|
+
disableMutations() {
|
|
2836
|
+
configs.get(uid).mutations = false;
|
|
2837
|
+
return this;
|
|
2838
|
+
},
|
|
2839
|
+
disableAction(action) {
|
|
2840
|
+
const config2 = configs.get(uid);
|
|
2841
|
+
if (!config2.disabledActions.includes(action)) {
|
|
2842
|
+
config2.disabledActions.push(action);
|
|
2843
|
+
}
|
|
2844
|
+
return this;
|
|
2845
|
+
},
|
|
2846
|
+
disableActions(actions = []) {
|
|
2847
|
+
actions.forEach((action) => this.disableAction(action));
|
|
2848
|
+
return this;
|
|
2849
|
+
},
|
|
2850
|
+
field(fieldName) {
|
|
2851
|
+
const { fields } = configs.get(uid);
|
|
2852
|
+
if (!fields.has(fieldName)) {
|
|
2853
|
+
fields.set(fieldName, getDefaultFieldConfig());
|
|
2854
|
+
}
|
|
2855
|
+
return {
|
|
2856
|
+
isEnabled() {
|
|
2857
|
+
return fields.get(fieldName).enabled;
|
|
2858
|
+
},
|
|
2859
|
+
hasInputEnabled() {
|
|
2860
|
+
return fields.get(fieldName).input;
|
|
2861
|
+
},
|
|
2862
|
+
hasOutputEnabled() {
|
|
2863
|
+
return fields.get(fieldName).output;
|
|
2864
|
+
},
|
|
2865
|
+
hasFiltersEnabeld() {
|
|
2866
|
+
return fields.get(fieldName).filters;
|
|
2867
|
+
},
|
|
2868
|
+
disable() {
|
|
2869
|
+
fields.set(fieldName, {
|
|
2870
|
+
enabled: false,
|
|
2871
|
+
output: false,
|
|
2872
|
+
input: false,
|
|
2873
|
+
filters: false
|
|
2874
|
+
});
|
|
2875
|
+
return this;
|
|
2876
|
+
},
|
|
2877
|
+
disableOutput() {
|
|
2878
|
+
fields.get(fieldName).output = false;
|
|
2879
|
+
return this;
|
|
2880
|
+
},
|
|
2881
|
+
disableInput() {
|
|
2882
|
+
fields.get(fieldName).input = false;
|
|
2883
|
+
return this;
|
|
2884
|
+
},
|
|
2885
|
+
disableFilters() {
|
|
2886
|
+
fields.get(fieldName).filters = false;
|
|
2887
|
+
return this;
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
};
|
|
2893
|
+
};
|
|
2894
|
+
const getDefaultState = () => ({
|
|
2895
|
+
types: [],
|
|
2896
|
+
typeDefs: [],
|
|
2897
|
+
resolvers: {},
|
|
2898
|
+
resolversConfig: {},
|
|
2899
|
+
plugins: []
|
|
2900
|
+
});
|
|
2901
|
+
const createExtension = ({ strapi: strapi2 }) => {
|
|
2902
|
+
const configs = [];
|
|
2903
|
+
return {
|
|
2904
|
+
shadowCRUD: createShadowCRUDManager(),
|
|
2905
|
+
/**
|
|
2906
|
+
* Register a new extension configuration
|
|
2907
|
+
*/
|
|
2908
|
+
use(configuration) {
|
|
2909
|
+
configs.push(configuration);
|
|
2910
|
+
return this;
|
|
2911
|
+
},
|
|
2912
|
+
/**
|
|
2913
|
+
* Convert the registered configuration into a single extension object & return it
|
|
2914
|
+
*/
|
|
2915
|
+
generate({ typeRegistry: typeRegistry2 }) {
|
|
2916
|
+
const resolveConfig = (config2) => {
|
|
2917
|
+
return typeof config2 === "function" ? config2({ strapi: strapi2, nexus: nexus__namespace, typeRegistry: typeRegistry2 }) : config2;
|
|
2918
|
+
};
|
|
2919
|
+
return configs.reduce((acc, configuration) => {
|
|
2920
|
+
const { types: types2, typeDefs, resolvers: resolvers2, resolversConfig, plugins } = resolveConfig(configuration);
|
|
2921
|
+
if (typeof typeDefs === "string") {
|
|
2922
|
+
acc.typeDefs.push(typeDefs);
|
|
2923
|
+
}
|
|
2924
|
+
if (Array.isArray(types2)) {
|
|
2925
|
+
acc.types.push(...types2);
|
|
2926
|
+
}
|
|
2927
|
+
if (Array.isArray(plugins)) {
|
|
2928
|
+
acc.plugins.push(...plugins);
|
|
2929
|
+
}
|
|
2930
|
+
if (typeof resolvers2 === "object") {
|
|
2931
|
+
acc.resolvers = fp.merge(acc.resolvers, resolvers2);
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof resolversConfig === "object") {
|
|
2934
|
+
acc.resolversConfig = fp.merge(resolversConfig, acc.resolversConfig);
|
|
2935
|
+
}
|
|
2936
|
+
return acc;
|
|
2937
|
+
}, getDefaultState());
|
|
2938
|
+
}
|
|
2939
|
+
};
|
|
2940
|
+
};
|
|
2941
|
+
const returnTypes = () => ({
|
|
2942
|
+
toEntityResponse(value, info = {}) {
|
|
2943
|
+
const { args: args2 = {}, resourceUID } = info;
|
|
2944
|
+
return { value, info: { args: args2, resourceUID } };
|
|
2945
|
+
},
|
|
2946
|
+
toEntityResponseCollection(nodes, info = {}) {
|
|
2947
|
+
const { args: args2 = {}, resourceUID } = info;
|
|
2948
|
+
return { nodes, info: { args: args2, resourceUID } };
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2951
|
+
const format = () => ({
|
|
2952
|
+
returnTypes: returnTypes()
|
|
2953
|
+
});
|
|
2954
|
+
const services = {
|
|
2955
|
+
builders,
|
|
2956
|
+
"content-api": contentAPI,
|
|
2957
|
+
constants,
|
|
2958
|
+
extension: createExtension,
|
|
2959
|
+
format,
|
|
2960
|
+
internals,
|
|
2961
|
+
"type-registry": typeRegistry,
|
|
2962
|
+
utils: utils$1
|
|
2963
|
+
};
|
|
2964
|
+
const index = {
|
|
2965
|
+
config,
|
|
2966
|
+
bootstrap,
|
|
2967
|
+
services
|
|
2968
|
+
};
|
|
2969
|
+
module.exports = index;
|
|
2970
|
+
//# sourceMappingURL=index.js.map
|