buro26-strapi-graphql 0.0.4 → 0.0.7
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/README.md +46 -46
- package/dist/server/bootstrap.d.ts +5 -0
- package/dist/server/bootstrap.js +5 -0
- package/dist/server/config/index.d.ts +5 -0
- package/dist/server/config/index.js +6 -0
- package/dist/server/content-types/index.d.ts +2 -0
- package/dist/server/content-types/index.js +3 -0
- package/dist/server/controllers/index.d.ts +6 -0
- package/dist/server/controllers/index.js +9 -0
- package/dist/server/controllers/my-controller.d.ts +5 -0
- package/dist/server/controllers/my-controller.js +3 -0
- package/dist/server/destroy.d.ts +5 -0
- package/dist/server/destroy.js +5 -0
- package/dist/server/index.d.ts +39 -0
- package/dist/server/index.js +45 -0
- package/dist/server/middlewares/index.d.ts +2 -0
- package/dist/server/middlewares/index.js +3 -0
- package/dist/server/policies/index.d.ts +2 -0
- package/dist/server/policies/index.js +3 -0
- package/dist/server/register.d.ts +5 -0
- package/dist/server/register.js +35 -0
- package/dist/server/routes/index.d.ts +2 -0
- package/dist/server/routes/index.js +3 -0
- package/dist/server/services/file-service.d.ts +8 -0
- package/dist/server/services/file-service.js +29 -0
- package/dist/server/services/graphql-service.d.ts +5 -0
- package/dist/server/services/graphql-service.js +3 -0
- package/dist/server/services/index.d.ts +11 -0
- package/dist/server/services/index.js +11 -0
- package/dist/server/services/my-service.js +7 -0
- package/{server/index.d.mts → dist/server/types.d.ts} +1 -12
- package/dist/server/types.js +2 -0
- package/dist/tsconfig.server.tsbuildinfo +1 -0
- package/package.json +60 -28
- package/strapi-server.js +3 -3
- package/LICENSE.md +0 -14
- package/server/index.d.ts +0 -38
- package/server/index.js +0 -96
- package/server/index.js.map +0 -1
- package/server/index.mjs +0 -66
- package/server/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# Strapi GraphQL Extension
|
|
2
|
-
|
|
3
|
-
Extension and utilities for Strapi GraphQL API.
|
|
4
|
-
|
|
5
|
-
## Getting started
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i buro26-strapi-graphql
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Configuration
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Test and Deploy
|
|
19
|
-
|
|
20
|
-
### Running tests
|
|
21
|
-
|
|
22
|
-
To run tests, run the following command:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
bun test
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Contributing
|
|
29
|
-
|
|
30
|
-
Wish to contribute to this project? Pull the project from the repository and create a merge request.
|
|
31
|
-
|
|
32
|
-
## Authors and acknowledgment
|
|
33
|
-
|
|
34
|
-
Buro26 - https://buro26.digital
|
|
35
|
-
Special thanks to all contributors and the open-source community for their support and contributions.
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
|
|
39
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
40
|
-
|
|
41
|
-
## Project status
|
|
42
|
-
|
|
43
|
-
The project is currently in active development. We are continuously working on adding new features and improving the
|
|
44
|
-
existing ones. Check the issues section for the latest updates and planned features.
|
|
45
|
-
|
|
46
|
-
Feel free to reach out if you have any questions or suggestions!
|
|
1
|
+
# Strapi GraphQL Extension
|
|
2
|
+
|
|
3
|
+
Extension and utilities for Strapi GraphQL API.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i buro26-strapi-graphql
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Configuration
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Test and Deploy
|
|
19
|
+
|
|
20
|
+
### Running tests
|
|
21
|
+
|
|
22
|
+
To run tests, run the following command:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bun test
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
Wish to contribute to this project? Pull the project from the repository and create a merge request.
|
|
31
|
+
|
|
32
|
+
## Authors and acknowledgment
|
|
33
|
+
|
|
34
|
+
Buro26 - https://buro26.digital
|
|
35
|
+
Special thanks to all contributors and the open-source community for their support and contributions.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
40
|
+
|
|
41
|
+
## Project status
|
|
42
|
+
|
|
43
|
+
The project is currently in active development. We are continuously working on adding new features and improving the
|
|
44
|
+
existing ones. Check the issues section for the latest updates and planned features.
|
|
45
|
+
|
|
46
|
+
Feel free to reach out if you have any questions or suggestions!
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const my_controller_1 = __importDefault(require("./my-controller"));
|
|
7
|
+
exports.default = {
|
|
8
|
+
myController: my_controller_1.default,
|
|
9
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Strapi } from "@strapi/strapi";
|
|
2
|
+
import { GraphQLExtension } from "./types";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
register: ({ strapi }: {
|
|
5
|
+
strapi: Strapi;
|
|
6
|
+
}) => void;
|
|
7
|
+
bootstrap: ({ strapi }: {
|
|
8
|
+
strapi: Strapi;
|
|
9
|
+
}) => void;
|
|
10
|
+
destroy: ({ strapi }: {
|
|
11
|
+
strapi: Strapi;
|
|
12
|
+
}) => void;
|
|
13
|
+
config: {
|
|
14
|
+
default: {};
|
|
15
|
+
validator(): void;
|
|
16
|
+
};
|
|
17
|
+
controllers: {
|
|
18
|
+
myController: ({ strapi }: {
|
|
19
|
+
strapi: Strapi;
|
|
20
|
+
}) => {};
|
|
21
|
+
};
|
|
22
|
+
routes: any[];
|
|
23
|
+
services: {
|
|
24
|
+
fileService: ({ strapi }: {
|
|
25
|
+
strapi: Strapi;
|
|
26
|
+
}) => {
|
|
27
|
+
getAllFilesInGraphQlDirectory(dirPath: string, arrayOfFiles?: GraphQLExtension[]): GraphQLExtension[];
|
|
28
|
+
};
|
|
29
|
+
graphQlService: ({ strapi }: {
|
|
30
|
+
strapi: Strapi;
|
|
31
|
+
}) => {};
|
|
32
|
+
};
|
|
33
|
+
contentTypes: {};
|
|
34
|
+
policies: {};
|
|
35
|
+
middlewares: {};
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
38
|
+
export * from './types';
|
|
39
|
+
export declare const createGraphQLExtension: (factory: (strapi: Strapi) => GraphQLExtension) => GraphQLExtension;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.createGraphQLExtension = void 0;
|
|
21
|
+
const register_1 = __importDefault(require("./register"));
|
|
22
|
+
const bootstrap_1 = __importDefault(require("./bootstrap"));
|
|
23
|
+
const destroy_1 = __importDefault(require("./destroy"));
|
|
24
|
+
const config_1 = __importDefault(require("./config"));
|
|
25
|
+
const content_types_1 = __importDefault(require("./content-types"));
|
|
26
|
+
const controllers_1 = __importDefault(require("./controllers"));
|
|
27
|
+
const routes_1 = __importDefault(require("./routes"));
|
|
28
|
+
const middlewares_1 = __importDefault(require("./middlewares"));
|
|
29
|
+
const policies_1 = __importDefault(require("./policies"));
|
|
30
|
+
const services_1 = __importDefault(require("./services"));
|
|
31
|
+
exports.default = {
|
|
32
|
+
register: register_1.default,
|
|
33
|
+
bootstrap: bootstrap_1.default,
|
|
34
|
+
destroy: destroy_1.default,
|
|
35
|
+
config: config_1.default,
|
|
36
|
+
controllers: controllers_1.default,
|
|
37
|
+
routes: routes_1.default,
|
|
38
|
+
services: services_1.default,
|
|
39
|
+
contentTypes: content_types_1.default,
|
|
40
|
+
policies: policies_1.default,
|
|
41
|
+
middlewares: middlewares_1.default,
|
|
42
|
+
};
|
|
43
|
+
__exportStar(require("./types"), exports);
|
|
44
|
+
const createGraphQLExtension = (factory) => factory(strapi);
|
|
45
|
+
exports.createGraphQLExtension = createGraphQLExtension;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const nexus_1 = require("nexus");
|
|
4
|
+
exports.default = ({ strapi }) => {
|
|
5
|
+
const fileService = strapi
|
|
6
|
+
.plugin('burotwosix-graphql-plugin')
|
|
7
|
+
.service('fileService');
|
|
8
|
+
const graphQlExtensionService = strapi
|
|
9
|
+
.plugin('graphql')
|
|
10
|
+
.service('extension');
|
|
11
|
+
console.log({
|
|
12
|
+
dirs: strapi.dirs,
|
|
13
|
+
});
|
|
14
|
+
const extensions = [
|
|
15
|
+
...fileService.getAllFilesInGraphQlDirectory(strapi.dirs.dist.src),
|
|
16
|
+
];
|
|
17
|
+
graphQlExtensionService.use(() => ({
|
|
18
|
+
plugins: [
|
|
19
|
+
(0, nexus_1.fieldAuthorizePlugin)(),
|
|
20
|
+
]
|
|
21
|
+
}));
|
|
22
|
+
for (const extension of extensions) {
|
|
23
|
+
(extension === null || extension === void 0 ? void 0 : extension.init) ? extension.init() : null;
|
|
24
|
+
graphQlExtensionService.use(() => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
return ({
|
|
27
|
+
types: (_b = (_a = extension === null || extension === void 0 ? void 0 : extension.getTypes) === null || _a === void 0 ? void 0 : _a.call(extension)) !== null && _b !== void 0 ? _b : [],
|
|
28
|
+
resolvers: (_d = (_c = extension === null || extension === void 0 ? void 0 : extension.resolvers) === null || _c === void 0 ? void 0 : _c.call(extension)) !== null && _d !== void 0 ? _d : { Query: {}, Mutation: {} },
|
|
29
|
+
resolversConfig: (_f = (_e = extension === null || extension === void 0 ? void 0 : extension.getResolverConfig) === null || _e === void 0 ? void 0 : _e.call(extension)) !== null && _f !== void 0 ? _f : {},
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
strapi.createGraphQLExtension = (factory) => factory(strapi);
|
|
35
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
import { GraphQLExtension } from "../types";
|
|
3
|
+
declare const _default: ({ strapi }: {
|
|
4
|
+
strapi: Strapi;
|
|
5
|
+
}) => {
|
|
6
|
+
getAllFilesInGraphQlDirectory(dirPath: string, arrayOfFiles?: GraphQLExtension[]): GraphQLExtension[];
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
exports.default = ({ strapi }) => ({
|
|
8
|
+
getAllFilesInGraphQlDirectory(dirPath, arrayOfFiles = []) {
|
|
9
|
+
const files = fs_1.default.readdirSync(dirPath);
|
|
10
|
+
files.forEach((file) => {
|
|
11
|
+
if (fs_1.default.statSync(dirPath + "/" + file).isDirectory()) {
|
|
12
|
+
arrayOfFiles = this.getAllFilesInGraphQlDirectory(dirPath + "/" + file, arrayOfFiles);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!dirPath.endsWith('/graphql') && !dirPath.includes('/graphql/')) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const ext = require(`${dirPath}/${file.replace('.js', '')}`);
|
|
19
|
+
if (!ext) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
arrayOfFiles.push({
|
|
23
|
+
...ext,
|
|
24
|
+
...(ext.default || {})
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return arrayOfFiles;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
fileService: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/strapi").Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
getAllFilesInGraphQlDirectory(dirPath: string, arrayOfFiles?: import("..").GraphQLExtension[]): import("..").GraphQLExtension[];
|
|
6
|
+
};
|
|
7
|
+
graphQlService: ({ strapi }: {
|
|
8
|
+
strapi: import("@strapi/strapi").Strapi;
|
|
9
|
+
}) => {};
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const file_service_1 = __importDefault(require("./file-service"));
|
|
7
|
+
const graphql_service_1 = __importDefault(require("./graphql-service"));
|
|
8
|
+
exports.default = {
|
|
9
|
+
fileService: file_service_1.default,
|
|
10
|
+
graphQlService: graphql_service_1.default,
|
|
11
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface GraphQLExtension {
|
|
1
|
+
export interface GraphQLExtension {
|
|
4
2
|
/**
|
|
5
3
|
* Called when the extension is initialized, use this to perform any initialization logic
|
|
6
4
|
* E.g. disabled CRUDs
|
|
@@ -27,12 +25,3 @@ interface GraphQLExtension {
|
|
|
27
25
|
*/
|
|
28
26
|
getResolverConfig: () => any;
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
declare const createGraphQLExtension: (factory: (strapi: Strapi) => GraphQLExtension) => GraphQLExtension;
|
|
32
|
-
declare const _default: {
|
|
33
|
-
register: ({ strapi }: {
|
|
34
|
-
strapi: Strapi;
|
|
35
|
-
}) => Promise<void>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { createGraphQLExtension, _default as default };
|