@apollo-elements/fast
Advanced tools
Comparing version 2.0.0-next.5 to 2.0.0-next.6
import type { ComponentDocument, Data, MaybeTDN, MaybeVariables, Variables } from '@apollo-elements/core/types'; | ||
import type { Behavior, ExecutionContext, FASTElement } from '@microsoft/fast-element'; | ||
import { ApolloMutationController, ApolloMutationControllerOptions } from '@apollo-elements/core/apollo-mutation-controller'; | ||
import { Behavior, FASTElement } from '@microsoft/fast-element'; | ||
/** | ||
@@ -20,4 +20,4 @@ * `ApolloMutationBehavior` | ||
constructor(hostElement: FASTElement & HTMLElement, mutation?: ComponentDocument<D> | null, options?: ApolloMutationControllerOptions<D, V>); | ||
bind(_source: FASTElement & HTMLElement, context: unknown): void; | ||
bind(_source: FASTElement & HTMLElement, _context: ExecutionContext): void; | ||
unbind(_source: FASTElement): void; | ||
} |
@@ -32,4 +32,3 @@ import { __decorate } from "tslib"; | ||
} | ||
bind(_source, context) { | ||
this.options.context = { ...context, ...this.options.context }; | ||
bind(_source, _context) { | ||
this.hostConnected(); | ||
@@ -39,2 +38,3 @@ } | ||
this.hostDisconnected(); | ||
this.host.removeController(this); | ||
} | ||
@@ -41,0 +41,0 @@ } |
import type { ComponentDocument, Data, MaybeTDN, MaybeVariables, Variables } from '@apollo-elements/core/types'; | ||
import type { Behavior, ExecutionContext, FASTElement } from '@microsoft/fast-element'; | ||
import { ApolloQueryController, ApolloQueryControllerOptions } from '@apollo-elements/core/apollo-query-controller'; | ||
import { Behavior, FASTElement } from '@microsoft/fast-element'; | ||
/** | ||
@@ -20,4 +20,4 @@ * `ApolloQueryBehavior` | ||
constructor(hostElement: FASTElement & HTMLElement, query?: ComponentDocument<D> | null, options?: ApolloQueryControllerOptions<D, V>); | ||
bind(_source: FASTElement & HTMLElement, context: unknown): void; | ||
bind(_source: FASTElement & HTMLElement, _context: ExecutionContext): void; | ||
unbind(_source: FASTElement): void; | ||
} |
@@ -32,4 +32,3 @@ import { __decorate } from "tslib"; | ||
} | ||
bind(_source, context) { | ||
this.options.context = { ...context, ...this.options.context }; | ||
bind(_source, _context) { | ||
this.hostConnected(); | ||
@@ -36,0 +35,0 @@ } |
import type { ComponentDocument, Data, MaybeTDN, MaybeVariables, Variables } from '@apollo-elements/core/types'; | ||
import type { Behavior, ExecutionContext, FASTElement } from '@microsoft/fast-element'; | ||
import { ApolloSubscriptionController, ApolloSubscriptionControllerOptions } from '@apollo-elements/core/apollo-subscription-controller'; | ||
import { Behavior, FASTElement } from '@microsoft/fast-element'; | ||
/** | ||
@@ -20,4 +20,4 @@ * `ApolloSubscriptionBehavior` | ||
constructor(hostElement: FASTElement & HTMLElement, subscription?: ComponentDocument<D> | null, options?: ApolloSubscriptionControllerOptions<D, V>); | ||
bind(_source: FASTElement & HTMLElement, context: unknown): void; | ||
bind(_source: FASTElement & HTMLElement, _context: ExecutionContext): void; | ||
unbind(_source: FASTElement): void; | ||
} |
@@ -32,4 +32,3 @@ import { __decorate } from "tslib"; | ||
} | ||
bind(_source, context) { | ||
this.options.context = { ...context, ...this.options.context }; | ||
bind(_source, _context) { | ||
this.hostConnected(); | ||
@@ -36,0 +35,0 @@ } |
@@ -6,3 +6,3 @@ import { __decorate } from "tslib"; | ||
import { controlled } from '@apollo-elements/core/decorators'; | ||
import { hosted } from '../decorators'; | ||
import { hosted } from './decorators'; | ||
/** | ||
@@ -69,3 +69,3 @@ * `ApolloElement` | ||
__decorate([ | ||
hosted(), | ||
hosted({ path: 'options' }), | ||
controlled({ path: 'options' }) | ||
@@ -72,0 +72,0 @@ ], ApolloElement.prototype, "context", void 0); |
@@ -33,5 +33,5 @@ import type * as C from '@apollo/client/core'; | ||
/** | ||
* An object that represents the result of this mutation that | ||
* will be optimistically stored before the server has actually returned a | ||
* result. | ||
* An object that represents the result of this mutation that will be optimistically | ||
* stored before the server has actually returned a result, or a unary function that | ||
* takes the mutation's variables and returns such an object. | ||
* | ||
@@ -41,2 +41,12 @@ * This is most often used for optimistic UI, where we want to be able to see | ||
* appear. | ||
* @example <caption>Using a function</caption> | ||
* ```ts | ||
* element.optimisticResponse = ({ name }: HelloMutationVariables) => ({ | ||
* __typename: 'Mutation', | ||
* hello: { | ||
* __typename: 'Greeting', | ||
* name, | ||
* }, | ||
* }); | ||
* ``` | ||
*/ | ||
@@ -43,0 +53,0 @@ optimisticResponse?: OptimisticResponseType<D, V>; |
@@ -6,3 +6,3 @@ import { __decorate } from "tslib"; | ||
import { ApolloMutationBehavior } from '../apollo-mutation-behavior.js'; | ||
import { hosted } from '../decorators.js'; | ||
import { hosted } from './decorators.js'; | ||
import { update } from '@apollo-elements/core/apollo-controller'; | ||
@@ -9,0 +9,0 @@ import { controlled } from '@apollo-elements/core/decorators'; |
@@ -63,4 +63,2 @@ /// <reference types="zen-observable" /> | ||
query: ComponentDocument<D> | null; | ||
/** @summary Context passed to the link execution chain. */ | ||
context?: Record<string, unknown>; | ||
/** | ||
@@ -67,0 +65,0 @@ * If data was read from the cache with missing fields, |
@@ -5,3 +5,3 @@ import { __decorate } from "tslib"; | ||
import { attr, nullableNumberConverter } from '@microsoft/fast-element'; | ||
import { hosted } from '../decorators.js'; | ||
import { hosted } from './decorators.js'; | ||
import { ApolloQueryBehavior } from '../apollo-query-behavior.js'; | ||
@@ -153,6 +153,2 @@ import { controlled } from '@apollo-elements/core/decorators'; | ||
controlled() | ||
], ApolloQuery.prototype, "context", void 0); | ||
__decorate([ | ||
hosted(), | ||
controlled() | ||
], ApolloQuery.prototype, "partial", void 0); | ||
@@ -159,0 +155,0 @@ __decorate([ |
@@ -6,4 +6,5 @@ import { __decorate } from "tslib"; | ||
import { FASTElement, customElement, html, DOM } from '@microsoft/fast-element'; | ||
import { describeQuery } from '@apollo-elements/test/query.test'; | ||
import { spy, useFakeTimers } from 'sinon'; | ||
import { assertType, isApolloError, setupSpies, setupStubs, stringify, } from '@apollo-elements/test'; | ||
import { describeQuery } from '@apollo-elements/test/query.test'; | ||
const template = html ` | ||
@@ -29,3 +30,3 @@ <output id="data">${x => stringify(x.data)}</output> | ||
let counter = -1; | ||
describe('[fast] ApolloQuery', function () { | ||
describe('[FAST] ApolloQuery', function () { | ||
describeQuery({ | ||
@@ -76,2 +77,38 @@ async setupFunction(opts) { | ||
}); | ||
describe('polling', function () { | ||
const name = 'polling-and-timers'; | ||
let Test = class Test extends ApolloQuery { | ||
}; | ||
Test = __decorate([ | ||
customElement({ name }) | ||
], Test); | ||
let element; | ||
let clock; | ||
beforeEach(async function () { | ||
element = await fixture(`<${name}></${name}>`); | ||
}); | ||
beforeEach(() => spy(element.controller, 'refetch')); | ||
beforeEach(() => { | ||
clock = useFakeTimers(); | ||
}); | ||
afterEach(() => clock.restore()); | ||
afterEach(() => { | ||
var _a, _b; | ||
(_b = (_a = element.controller.refetch).restore) === null || _b === void 0 ? void 0 : _b.call(_a); | ||
}); | ||
describe('calling startPolling(1000)', function () { | ||
beforeEach(function startPolling() { element.startPolling(1000); }); | ||
beforeEach(() => { clock.tick(3500); }); | ||
it('refetches', function () { | ||
expect(element.controller.refetch).to.have.been.calledThrice; | ||
}); | ||
describe('then stopPolling', function () { | ||
beforeEach(function stopPolling() { element.stopPolling(); }); | ||
beforeEach(() => { clock.tick(3500); }); | ||
it('stops calling refetch', function () { | ||
expect(element.controller.refetch).to.have.been.calledThrice; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -78,0 +115,0 @@ class TypeCheck extends ApolloQuery { |
import { __decorate } from "tslib"; | ||
import { ApolloElement } from './apollo-element.js'; | ||
import { attr, nullableNumberConverter } from '@microsoft/fast-element'; | ||
import { hosted } from '../decorators.js'; | ||
import { hosted } from './decorators.js'; | ||
import { ApolloSubscriptionBehavior } from '../apollo-subscription-behavior.js'; | ||
@@ -6,0 +6,0 @@ import { controlled } from '@apollo-elements/core/decorators'; |
import { __decorate } from "tslib"; | ||
import { setupSpies, setupStubs, stringify, } from '@apollo-elements/test'; | ||
import * as S from '@apollo-elements/test/schema'; | ||
import { setupClient, setupSpies, setupStubs, stringify, teardownClient, } from '@apollo-elements/test'; | ||
import { expect, fixture } from '@open-wc/testing'; | ||
@@ -27,3 +28,3 @@ import { html as h, unsafeStatic } from 'lit/static-html.js'; | ||
let counter = 1; | ||
describe('[fast] ApolloSubscription', function () { | ||
describe('[FAST] ApolloSubscription', function () { | ||
describeSubscription({ | ||
@@ -72,2 +73,22 @@ async setupFunction(opts) { | ||
}); | ||
it('renders on error', async function () { | ||
var _a; | ||
setupClient(); | ||
const name = 'renders-on-error'; | ||
const template = html `${x => { var _a, _b; return (_b = (_a = x.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'FAIL'; }}`; | ||
let Test = class Test extends ApolloSubscription { | ||
constructor() { | ||
super(...arguments); | ||
this.subscription = S.NullableParamSubscription; | ||
this.variables = { nullable: 'error' }; | ||
} | ||
}; | ||
Test = __decorate([ | ||
customElement({ name, template }) | ||
], Test); | ||
const tag = unsafeStatic(name); | ||
const element = await fixture(h `<${tag}></${tag}>`); | ||
expect((_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.textContent).to.be.ok.and.to.not.contain('FAIL'); | ||
teardownClient(); | ||
}); | ||
}); | ||
@@ -74,0 +95,0 @@ }); |
{ | ||
"name": "@apollo-elements/fast", | ||
"version": "2.0.0-next.5", | ||
"version": "2.0.0-next.6", | ||
"description": "👩🚀🌛 FastElements for Apollo GraphQL 🚀👨🚀", | ||
@@ -51,6 +51,2 @@ "main": "index.js", | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.com" | ||
}, | ||
"repository": { | ||
@@ -76,4 +72,4 @@ "type": "git", | ||
"dependencies": { | ||
"@apollo-elements/core": "^0.0.1-next.4", | ||
"@apollo-elements/mixins": "^4.0.0-next.4", | ||
"@apollo-elements/core": "^0.0.1-next.5", | ||
"@apollo-elements/mixins": "^4.0.0-next.5", | ||
"@microsoft/fast-element": "^1.4.0", | ||
@@ -80,0 +76,0 @@ "tslib": "^2.3.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
270589
59
52
4008
0