@apollo-elements/fast
Version:
👩🚀🌛 FastElements for Apollo GraphQL 🚀👨🚀
60 lines (48 loc) • 1.66 kB
JavaScript
import { __decorate } from "tslib";
import { ApolloMutationController as AMC } from '@apollo-elements/core/apollo-mutation-controller';
import { Observable, observable } from '@microsoft/fast-element';
import { FASTControllerHost } from './fast-controller-host';
/**
* `ApolloMutationBehavior`
*
* 🚀 FAST Behavior that connects to your Apollo cache.
*/
export class ApolloMutationBehavior extends AMC {
constructor(hostElement, mutation, options) {
super(new FASTControllerHost(hostElement), mutation, { ...options,
hostElement
});
this.hostElement = hostElement;
/**
* Latest query data.
*/
this.data = null;
this.called = false;
this.loading = false;
this.error = null;
this.errors = [];
this.variables = options?.variables ?? null;
hostElement.$fastController.addBehaviors([this]);
}
get variables() {
Observable.track(this, 'variables');
return super.variables;
}
set variables(value) {
super.variables = value;
Observable.notify(this, 'variables');
}
bind(_source, _context) {
this.hostConnected();
}
unbind(_source) {
this.hostDisconnected();
this.host.removeController(this);
}
}
__decorate([observable], ApolloMutationBehavior.prototype, "data", void 0);
__decorate([observable], ApolloMutationBehavior.prototype, "called", void 0);
__decorate([observable], ApolloMutationBehavior.prototype, "loading", void 0);
__decorate([observable], ApolloMutationBehavior.prototype, "error", void 0);
__decorate([observable], ApolloMutationBehavior.prototype, "errors", void 0);
//# sourceMappingURL=apollo-mutation-behavior.js.map