@vendure/graphiql-plugin 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +42 -0
- package/README.md +78 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/graphiql/assets/Range-CZNrBk8u.js +2 -0
- package/dist/graphiql/assets/Range-CZNrBk8u.js.map +1 -0
- package/dist/graphiql/assets/SchemaReference-BkXpFjYE.js +2 -0
- package/dist/graphiql/assets/SchemaReference-BkXpFjYE.js.map +1 -0
- package/dist/graphiql/assets/brace-fold-G8s_VF30.js +2 -0
- package/dist/graphiql/assets/brace-fold-G8s_VF30.js.map +1 -0
- package/dist/graphiql/assets/closebrackets-CRdA-72-.js +3 -0
- package/dist/graphiql/assets/closebrackets-CRdA-72-.js.map +1 -0
- package/dist/graphiql/assets/codemirror-ByTr8a86.js +2 -0
- package/dist/graphiql/assets/codemirror-ByTr8a86.js.map +1 -0
- package/dist/graphiql/assets/codemirror-HbUmq4EM.js +25 -0
- package/dist/graphiql/assets/codemirror-HbUmq4EM.js.map +1 -0
- package/dist/graphiql/assets/comment-CGefoK3-.js +3 -0
- package/dist/graphiql/assets/comment-CGefoK3-.js.map +1 -0
- package/dist/graphiql/assets/dialog-BO974A8g.js +2 -0
- package/dist/graphiql/assets/dialog-BO974A8g.js.map +1 -0
- package/dist/graphiql/assets/dialog-BwC5n760.js +2 -0
- package/dist/graphiql/assets/dialog-BwC5n760.js.map +1 -0
- package/dist/graphiql/assets/foldgutter-D9cIGUuP.js +2 -0
- package/dist/graphiql/assets/foldgutter-D9cIGUuP.js.map +1 -0
- package/dist/graphiql/assets/forEachState-C8esYVuF.js +2 -0
- package/dist/graphiql/assets/forEachState-C8esYVuF.js.map +1 -0
- package/dist/graphiql/assets/hint-BD7tZw-p.js +2 -0
- package/dist/graphiql/assets/hint-BD7tZw-p.js.map +1 -0
- package/dist/graphiql/assets/hint-C002w0QS.js +2 -0
- package/dist/graphiql/assets/hint-C002w0QS.js.map +1 -0
- package/dist/graphiql/assets/index-B6eyM87L.css +1 -0
- package/dist/graphiql/assets/index-CVlvTGMf.js +2 -0
- package/dist/graphiql/assets/index-CVlvTGMf.js.map +1 -0
- package/dist/graphiql/assets/index-vgxUfc3s.js +375 -0
- package/dist/graphiql/assets/index-vgxUfc3s.js.map +1 -0
- package/dist/graphiql/assets/info-BoLC3SPi.js +2 -0
- package/dist/graphiql/assets/info-BoLC3SPi.js.map +1 -0
- package/dist/graphiql/assets/info-addon-C6pf9J2z.js +2 -0
- package/dist/graphiql/assets/info-addon-C6pf9J2z.js.map +1 -0
- package/dist/graphiql/assets/javascript-C8NtILvq.js +2 -0
- package/dist/graphiql/assets/javascript-C8NtILvq.js.map +1 -0
- package/dist/graphiql/assets/jump-DyFqt083.js +2 -0
- package/dist/graphiql/assets/jump-DyFqt083.js.map +1 -0
- package/dist/graphiql/assets/jump-to-line-Cnc_EcEP.js +2 -0
- package/dist/graphiql/assets/jump-to-line-Cnc_EcEP.js.map +1 -0
- package/dist/graphiql/assets/lint-DibpxzPv.js +2 -0
- package/dist/graphiql/assets/lint-DibpxzPv.js.map +1 -0
- package/dist/graphiql/assets/lint-muFCMcrU.js +7 -0
- package/dist/graphiql/assets/lint-muFCMcrU.js.map +1 -0
- package/dist/graphiql/assets/lint-uXarRgMn.js +2 -0
- package/dist/graphiql/assets/lint-uXarRgMn.js.map +1 -0
- package/dist/graphiql/assets/matchbrackets-D7CjVzEn.js +2 -0
- package/dist/graphiql/assets/matchbrackets-D7CjVzEn.js.map +1 -0
- package/dist/graphiql/assets/matchbrackets-DRv12Ane.js +2 -0
- package/dist/graphiql/assets/matchbrackets-DRv12Ane.js.map +1 -0
- package/dist/graphiql/assets/mode-B2yzrHw3.js +2 -0
- package/dist/graphiql/assets/mode-B2yzrHw3.js.map +1 -0
- package/dist/graphiql/assets/mode-DXzohsjS.js +2 -0
- package/dist/graphiql/assets/mode-DXzohsjS.js.map +1 -0
- package/dist/graphiql/assets/mode-ELYjgi2B.js +2 -0
- package/dist/graphiql/assets/mode-ELYjgi2B.js.map +1 -0
- package/dist/graphiql/assets/mode-indent-Dvf_-b54.js +2 -0
- package/dist/graphiql/assets/mode-indent-Dvf_-b54.js.map +1 -0
- package/dist/graphiql/assets/search-Dr90Mq3g.js +3 -0
- package/dist/graphiql/assets/search-Dr90Mq3g.js.map +1 -0
- package/dist/graphiql/assets/searchcursor-DThQw5sX.js +8 -0
- package/dist/graphiql/assets/searchcursor-DThQw5sX.js.map +1 -0
- package/dist/graphiql/assets/searchcursor-DzZ5Qe8O.js +2 -0
- package/dist/graphiql/assets/searchcursor-DzZ5Qe8O.js.map +1 -0
- package/dist/graphiql/assets/show-hint-AM0FN_bp.js +2 -0
- package/dist/graphiql/assets/show-hint-AM0FN_bp.js.map +1 -0
- package/dist/graphiql/assets/sublime-DjfxhwhR.js +7 -0
- package/dist/graphiql/assets/sublime-DjfxhwhR.js.map +1 -0
- package/dist/graphiql/index.html +13 -0
- package/dist/graphiql.service.d.ts +21 -0
- package/dist/graphiql.service.js +61 -0
- package/dist/graphiql.service.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +43 -0
- package/dist/plugin.js +147 -0
- package/dist/plugin.js.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GraphiQLService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@vendure/core");
|
|
15
|
+
/**
|
|
16
|
+
* This service is responsible for providing GraphiQL configuration
|
|
17
|
+
* and a fallback UI if needed.
|
|
18
|
+
*/
|
|
19
|
+
let GraphiQLService = class GraphiQLService {
|
|
20
|
+
constructor(configService) {
|
|
21
|
+
this.configService = configService;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the Admin API URL
|
|
25
|
+
*/
|
|
26
|
+
getAdminApiUrl() {
|
|
27
|
+
const adminApiPath = this.configService.apiOptions.adminApiPath || 'admin-api';
|
|
28
|
+
return this.createApiUrl(adminApiPath);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the Shop API URL
|
|
32
|
+
*/
|
|
33
|
+
getShopApiUrl() {
|
|
34
|
+
const shopApiPath = this.configService.apiOptions.shopApiPath || 'shop-api';
|
|
35
|
+
return this.createApiUrl(shopApiPath);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a fully-qualified API URL
|
|
39
|
+
*/
|
|
40
|
+
createApiUrl(apiPath) {
|
|
41
|
+
// Get API host and port from the config
|
|
42
|
+
const apiHost = this.configService.apiOptions.hostname || '';
|
|
43
|
+
const apiPort = this.configService.apiOptions.port || '';
|
|
44
|
+
const host = apiHost || '';
|
|
45
|
+
const port = apiPort ? `:${apiPort}` : '';
|
|
46
|
+
const pathUrl = apiPath.startsWith('/') ? apiPath : `/${apiPath}`;
|
|
47
|
+
// If the host is specified, create a fully-qualified URL
|
|
48
|
+
if (host) {
|
|
49
|
+
const protocol = host.startsWith('https') ? '' : 'http://';
|
|
50
|
+
return `${protocol}${host}${port}${pathUrl}`;
|
|
51
|
+
}
|
|
52
|
+
// Otherwise use a relative URL
|
|
53
|
+
return pathUrl;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.GraphiQLService = GraphiQLService;
|
|
57
|
+
exports.GraphiQLService = GraphiQLService = __decorate([
|
|
58
|
+
(0, common_1.Injectable)(),
|
|
59
|
+
__metadata("design:paramtypes", [core_1.ConfigService])
|
|
60
|
+
], GraphiQLService);
|
|
61
|
+
//# sourceMappingURL=graphiql.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphiql.service.js","sourceRoot":"","sources":["../src/graphiql.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wCAA8C;AAE9C;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAEpD;;OAEG;IACH,cAAc;QACV,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,YAAY,IAAI,WAAW,CAAC;QAC/E,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,aAAa;QACT,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC;QAC5E,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,OAAe;QAChC,wCAAwC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;QAEzD,MAAM,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;QAElE,yDAAyD;QACzD,IAAI,IAAI,EAAE,CAAC;YACP,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3D,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,EAAE,CAAC;QACjD,CAAC;QAED,+BAA+B;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ,CAAA;AAxCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAE0B,oBAAa;GADvC,eAAe,CAwC3B"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* The GraphiQL plugin exports a server plugin which serves
|
|
20
|
+
* a GraphQL playground for the admin & shop APIs.
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./plugin"), exports);
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,2CAAyB;AACzB,0CAAwB"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
|
+
import { Type } from '@vendure/common/lib/shared-types';
|
|
3
|
+
import { ConfigService, ProcessContext } from '@vendure/core';
|
|
4
|
+
import { GraphiQLService } from './graphiql.service';
|
|
5
|
+
import { GraphiqlPluginOptions } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* @description
|
|
8
|
+
* This plugin provides a GraphiQL UI for exploring and testing the Vendure GraphQL APIs.
|
|
9
|
+
*
|
|
10
|
+
* It adds routes `/graphiql/admin` and `/graphiql/shop` which serve the GraphiQL interface
|
|
11
|
+
* for the respective APIs.
|
|
12
|
+
*
|
|
13
|
+
* ## Installation
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { GraphiQLPlugin } from '\@vendure/graphiql-plugin';
|
|
17
|
+
*
|
|
18
|
+
* const config: VendureConfig = {
|
|
19
|
+
* // Add an instance of the plugin to the plugins array
|
|
20
|
+
* plugins: [
|
|
21
|
+
* GraphiQLPlugin.init({
|
|
22
|
+
* route: 'graphiql', // Optional, defaults to 'graphiql'
|
|
23
|
+
* }),
|
|
24
|
+
* ],
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @docsCategory core plugins/GraphiqlPlugin
|
|
29
|
+
*/
|
|
30
|
+
export declare class GraphiqlPlugin implements NestModule {
|
|
31
|
+
private readonly processContext;
|
|
32
|
+
private readonly configService;
|
|
33
|
+
private readonly graphiQLService;
|
|
34
|
+
static options: Required<GraphiqlPluginOptions>;
|
|
35
|
+
constructor(processContext: ProcessContext, configService: ConfigService, graphiQLService: GraphiQLService);
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the plugin with the given options.
|
|
38
|
+
*/
|
|
39
|
+
static init(options?: GraphiqlPluginOptions): Type<GraphiqlPlugin>;
|
|
40
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
41
|
+
private createStaticServer;
|
|
42
|
+
private createAssetsServer;
|
|
43
|
+
}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var GraphiqlPlugin_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GraphiqlPlugin = void 0;
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const constants_1 = require("./constants");
|
|
21
|
+
const graphiql_service_1 = require("./graphiql.service");
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* This plugin provides a GraphiQL UI for exploring and testing the Vendure GraphQL APIs.
|
|
25
|
+
*
|
|
26
|
+
* It adds routes `/graphiql/admin` and `/graphiql/shop` which serve the GraphiQL interface
|
|
27
|
+
* for the respective APIs.
|
|
28
|
+
*
|
|
29
|
+
* ## Installation
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { GraphiQLPlugin } from '\@vendure/graphiql-plugin';
|
|
33
|
+
*
|
|
34
|
+
* const config: VendureConfig = {
|
|
35
|
+
* // Add an instance of the plugin to the plugins array
|
|
36
|
+
* plugins: [
|
|
37
|
+
* GraphiQLPlugin.init({
|
|
38
|
+
* route: 'graphiql', // Optional, defaults to 'graphiql'
|
|
39
|
+
* }),
|
|
40
|
+
* ],
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @docsCategory core plugins/GraphiqlPlugin
|
|
45
|
+
*/
|
|
46
|
+
let GraphiqlPlugin = GraphiqlPlugin_1 = class GraphiqlPlugin {
|
|
47
|
+
constructor(processContext, configService, graphiQLService) {
|
|
48
|
+
this.processContext = processContext;
|
|
49
|
+
this.configService = configService;
|
|
50
|
+
this.graphiQLService = graphiQLService;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the plugin with the given options.
|
|
54
|
+
*/
|
|
55
|
+
static init(options = {}) {
|
|
56
|
+
this.options = Object.assign(Object.assign({}, options), { route: options.route || 'graphiql' });
|
|
57
|
+
return GraphiqlPlugin_1;
|
|
58
|
+
}
|
|
59
|
+
configure(consumer) {
|
|
60
|
+
if (!this.processContext.isServer) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const adminRoute = GraphiqlPlugin_1.options.route + '/admin';
|
|
64
|
+
const shopRoute = GraphiqlPlugin_1.options.route + '/shop';
|
|
65
|
+
consumer.apply(this.createStaticServer()).forRoutes(adminRoute);
|
|
66
|
+
consumer.apply(this.createStaticServer()).forRoutes(shopRoute);
|
|
67
|
+
// Add middleware for serving assets
|
|
68
|
+
consumer.apply(this.createAssetsServer()).forRoutes('/graphiql/assets/*path');
|
|
69
|
+
(0, core_1.registerPluginStartupMessage)('GraphiQL Admin', adminRoute);
|
|
70
|
+
(0, core_1.registerPluginStartupMessage)('GraphiQL Shop', shopRoute);
|
|
71
|
+
}
|
|
72
|
+
createStaticServer() {
|
|
73
|
+
const distDir = path_1.default.join(__dirname, '../dist/graphiql');
|
|
74
|
+
const adminApiUrl = this.graphiQLService.getAdminApiUrl();
|
|
75
|
+
const shopApiUrl = this.graphiQLService.getShopApiUrl();
|
|
76
|
+
return (req, res) => {
|
|
77
|
+
try {
|
|
78
|
+
const indexHtmlPath = path_1.default.join(distDir, 'index.html');
|
|
79
|
+
if (fs_1.default.existsSync(indexHtmlPath)) {
|
|
80
|
+
// Read the HTML file
|
|
81
|
+
let html = fs_1.default.readFileSync(indexHtmlPath, 'utf-8');
|
|
82
|
+
// Inject API URLs
|
|
83
|
+
html = html.replace('</head>', `<script>
|
|
84
|
+
window.GRAPHIQL_SETTINGS = {
|
|
85
|
+
adminApiUrl: "${adminApiUrl}",
|
|
86
|
+
shopApiUrl: "${shopApiUrl}"
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
89
|
+
</head>`);
|
|
90
|
+
return res.send(html);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`GraphiQL UI not found: ${indexHtmlPath}`);
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
const errorMessage = e instanceof Error ? e.message : 'Unknown error';
|
|
96
|
+
core_1.Logger.error(`Error serving GraphiQL: ${errorMessage}`, 'GraphiQLPlugin');
|
|
97
|
+
return res.status(500).send('An error occurred while rendering GraphiQL');
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
createAssetsServer() {
|
|
102
|
+
const distDir = path_1.default.join(__dirname, '../dist/graphiql');
|
|
103
|
+
return (req, res, next) => {
|
|
104
|
+
try {
|
|
105
|
+
// Extract asset path from URL
|
|
106
|
+
const assetPath = req.params[0] || req.params.path || '';
|
|
107
|
+
const filePath = path_1.default.join(distDir, 'assets', assetPath.toString());
|
|
108
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
109
|
+
return res.sendFile(filePath);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return res.status(404).send('Asset not found');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
const errorMessage = e instanceof Error ? e.message : 'Unknown error';
|
|
117
|
+
core_1.Logger.error(`Error serving static asset: ${errorMessage}`, constants_1.loggerCtx);
|
|
118
|
+
return res.status(500).send('An error occurred while serving static asset');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
exports.GraphiqlPlugin = GraphiqlPlugin;
|
|
124
|
+
exports.GraphiqlPlugin = GraphiqlPlugin = GraphiqlPlugin_1 = __decorate([
|
|
125
|
+
(0, core_1.VendurePlugin)({
|
|
126
|
+
imports: [core_1.PluginCommonModule],
|
|
127
|
+
providers: [
|
|
128
|
+
graphiql_service_1.GraphiQLService,
|
|
129
|
+
{
|
|
130
|
+
provide: constants_1.PLUGIN_INIT_OPTIONS,
|
|
131
|
+
useFactory: () => GraphiqlPlugin.options,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
configuration: config => {
|
|
135
|
+
// disable GraphQL playground in config
|
|
136
|
+
config.apiOptions.adminApiPlayground = false;
|
|
137
|
+
config.apiOptions.shopApiPlayground = false;
|
|
138
|
+
return config;
|
|
139
|
+
},
|
|
140
|
+
exports: [graphiql_service_1.GraphiQLService],
|
|
141
|
+
compatibility: '^3.0.0',
|
|
142
|
+
}),
|
|
143
|
+
__metadata("design:paramtypes", [core_1.ProcessContext,
|
|
144
|
+
core_1.ConfigService,
|
|
145
|
+
graphiql_service_1.GraphiQLService])
|
|
146
|
+
], GraphiqlPlugin);
|
|
147
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,wCAOuB;AAEvB,4CAAoB;AACpB,gDAAwB;AAExB,2CAA6D;AAC7D,yDAAqD;AAGrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAmBI,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGvB,YACqB,cAA8B,EAC9B,aAA4B,EAC5B,eAAgC;QAFhC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,kBAAa,GAAb,aAAa,CAAe;QAC5B,oBAAe,GAAf,eAAe,CAAiB;IAClD,CAAC;IAEJ;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,UAAiC,EAAE;QAC3C,IAAI,CAAC,OAAO,mCACL,OAAO,KACV,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,UAAU,GACrC,CAAC;QACF,OAAO,gBAAc,CAAC;IAC1B,CAAC;IAED,SAAS,CAAC,QAA4B;QAClC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,MAAM,UAAU,GAAG,gBAAc,CAAC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;QAC3D,MAAM,SAAS,GAAG,gBAAc,CAAC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC;QAEzD,QAAQ,CAAC,KAAK,CAA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AAC;gBACvE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;YAChF,CAAC;QACL,CAAC,CAAC;IACN,CAAC;CACJ,CAAA;AAjGY,wCAAc;yBAAd,cAAc;IAlB1B,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE;YACP,kCAAe;YACf;gBACI,OAAO,EAAE,+BAAmB;gBAC5B,UAAU,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO;aAC3C;SACJ;QACD,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,uCAAuC;YACvC,MAAM,CAAC,UAAU,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAC7C,MAAM,CAAC,UAAU,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC5C,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,EAAE,CAAC,kCAAe,CAAC;QAC1B,aAAa,EAAE,QAAQ;KAC1B,CAAC;qCAKuC,qBAAc;QACf,oBAAa;QACX,kCAAe;GAN5C,cAAc,CAiG1B"}
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vendure/graphiql-plugin",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"license": "GPL-3.0-or-later",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/vendure-ecommerce/vendure"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
16
|
+
"build": "rimraf dist && npm run build:app && tsc -p ./tsconfig.build.json",
|
|
17
|
+
"build:app": "vite build",
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"lint": "eslint --fix .",
|
|
20
|
+
"test": "vitest --config vitest.config.mts --run",
|
|
21
|
+
"e2e": "cross-env PACKAGE=graphiql-plugin vitest --config ../../e2e-common/vitest.config.mts --run"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://www.vendure.io/",
|
|
24
|
+
"funding": "https://github.com/sponsors/michaelbromley",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"express": "^5.1.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@graphiql/toolkit": "^0.11.1",
|
|
33
|
+
"@types/express": "^5.0.0",
|
|
34
|
+
"@types/react": "^19.0.0",
|
|
35
|
+
"@types/react-dom": "^19.0.0",
|
|
36
|
+
"@vendure/common": "3.3.0",
|
|
37
|
+
"@vendure/core": "3.3.0",
|
|
38
|
+
"@vitejs/plugin-react": "^4.4.1",
|
|
39
|
+
"graphiql": "^4.0.2",
|
|
40
|
+
"react": "^19.0.0",
|
|
41
|
+
"react-dom": "^19.0.0",
|
|
42
|
+
"rimraf": "^6.0.1",
|
|
43
|
+
"vite": "^6.3.5",
|
|
44
|
+
"vite-plugin-dts": "^4.5.3"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "a4c56359ec831b0c54dd01eab14fb75455c43ab7"
|
|
47
|
+
}
|