@apollo/core-schema
Version:
Apollo Core Schema processing library
78 lines • 3.29 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.byGref = exports.GRef = void 0;
const recall_1 = __importStar(require("@protoplasm/recall"));
const each_1 = require("./each");
const link_url_1 = __importDefault(require("./link-url"));
class GRef {
constructor(name, graph) {
this.name = name;
this.graph = graph;
}
static canon(name, graph) {
return new this(name, graph);
}
static named(name, graph) {
return this.canon(name, link_url_1.default.from(graph));
}
static directive(name, graph) {
return this.canon('@' + name, link_url_1.default.from(graph));
}
static rootDirective(graph) {
return this.directive('', graph);
}
static schema(graph) {
return this.canon('', link_url_1.default.from(graph));
}
setGraph(graph) {
return GRef.canon(this.name, link_url_1.default.from(graph));
}
setName(name) {
return GRef.canon(name, this.graph);
}
toString() {
var _a, _b;
const graph = (_b = (_a = this.graph) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : '';
return graph + (this.name ? `#${this.name}` : '');
}
isSchema() { return this.name === ''; }
}
__decorate([
(0, recall_1.use)(recall_1.default)
], GRef, "canon", null);
exports.GRef = GRef;
exports.default = GRef;
exports.byGref = (0, each_1.groupBy)((node) => node === null || node === void 0 ? void 0 : node.gref);
//# sourceMappingURL=gref.js.map