@theguild/federation-composition
Version:
Open Source Composition library for Apollo Federation
52 lines (51 loc) • 1.3 kB
JavaScript
import { lazy } from './helpers.js';
export class FieldMove {
typeName;
fieldName;
requires;
provides;
provided;
_toString = lazy(() => {
let str = this.fieldName;
if (this.requires) {
str += ` `;
}
if (this.provides) {
str += ` `;
}
if (this.provided) {
str += ' @provided';
}
return str;
});
constructor(typeName, fieldName, requires = null, provides = null, provided = false) {
this.typeName = typeName;
this.fieldName = fieldName;
this.requires = requires;
this.provides = provides;
this.provided = provided;
}
toString() {
return this._toString.get();
}
}
export class AbstractMove {
keyFields;
_toString = lazy(() => (this.keyFields ? `🔮 🔑 ${this.keyFields}` : `🔮`));
constructor(keyFields) {
this.keyFields = keyFields;
}
toString() {
return this._toString.get();
}
}
export class EntityMove {
keyFields;
_toString = lazy(() => `🔑 ${this.keyFields}`);
constructor(keyFields) {
this.keyFields = keyFields;
}
toString() {
return this._toString.get();
}
}