@apollo-elements/fast
Advanced tools
Comparing version 1.2.3 to 1.3.0-alpha.0
@@ -1,9 +0,13 @@ | ||
import type { ApolloElementInterface } from '@apollo-elements/interfaces/apollo-element'; | ||
import type { Constructor, CustomElement, Data, GraphQLError, Variables } from '@apollo-elements/interfaces'; | ||
import type { ApolloClient, ApolloError, NormalizedCacheObject, OperationVariables } from '@apollo/client/core'; | ||
import type { GraphQLError } from '@apollo-elements/interfaces'; | ||
import type { ApolloClient, ApolloError, NormalizedCacheObject } from '@apollo/client/core'; | ||
import { FASTElement } from '@microsoft/fast-element'; | ||
declare const ApolloElement_base: { | ||
new <D_1 = unknown, V_1 = Record<string, any>>(...a: any[]): ApolloElementInterface<D_1, V_1>; | ||
documentType: "query" | "mutation" | "subscription" | "document"; | ||
} & Constructor<CustomElement & FASTElement>; | ||
declare const ApolloElement_base: import("@apollo-elements/interfaces").Constructor<import("@apollo-elements/interfaces").ApolloElementInterface> & Pick<typeof import("@apollo-elements/interfaces").ApolloElementInterface, "prototype" | "documentType"> & { | ||
observedAttributes?: string[] | undefined; | ||
} & (new () => HTMLElement & FASTElement) & { | ||
from<TBase extends { | ||
new (): HTMLElement; | ||
prototype: HTMLElement; | ||
}>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement; | ||
define<TType extends Function>(type: TType, nameOrDef?: string | import("@microsoft/fast-element").PartialFASTElementDefinition | undefined): TType; | ||
}; | ||
/** | ||
@@ -18,7 +22,7 @@ * `ApolloElement` | ||
*/ | ||
export declare class ApolloElement<D = unknown, V = OperationVariables> extends ApolloElement_base<D, V> implements ApolloElementInterface<D, V> { | ||
export declare class ApolloElement extends ApolloElement_base { | ||
context?: Record<string, unknown>; | ||
variables: Variables<D, V>; | ||
variables: unknown | null; | ||
data: unknown | null; | ||
client: ApolloClient<NormalizedCacheObject> | null; | ||
data: Data<D> | null; | ||
error: ApolloError | Error | null; | ||
@@ -25,0 +29,0 @@ errors: readonly GraphQLError[] | null; |
@@ -13,10 +13,8 @@ import { __decorate } from "tslib"; | ||
*/ | ||
export class ApolloElement | ||
// have to cast because of the TypeScript bug which causes the error in apollo-element-mixin | ||
extends ApolloElementMixin(FASTElement) { | ||
export class ApolloElement extends ApolloElementMixin(FASTElement) { | ||
constructor() { | ||
var _a; | ||
super(...arguments); | ||
this.data = null; | ||
this.client = (_a = window.__APOLLO_CLIENT__) !== null && _a !== void 0 ? _a : null; | ||
this.data = null; | ||
this.error = null; | ||
@@ -29,6 +27,6 @@ this.errors = null; | ||
observable | ||
], ApolloElement.prototype, "client", void 0); | ||
], ApolloElement.prototype, "data", void 0); | ||
__decorate([ | ||
observable | ||
], ApolloElement.prototype, "data", void 0); | ||
], ApolloElement.prototype, "client", void 0); | ||
__decorate([ | ||
@@ -35,0 +33,0 @@ observable |
@@ -38,14 +38,2 @@ import { __decorate } from "tslib"; | ||
}); | ||
it('renders when data is set', async function rendersOnData() { | ||
const name = 'renders-when-data-is-set'; | ||
const template = html `${x => { var _a, _b; return (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.foo) !== null && _b !== void 0 ? _b : 'FAIL'; }}`; | ||
let Test = class Test extends ApolloElement { | ||
}; | ||
Test = __decorate([ | ||
customElement({ name, template }) | ||
], Test); | ||
const tag = unsafeStatic(name); | ||
const element = await fixture(fhtml `<${tag} .data="${{ foo: 'bar' }}"></${tag}>`); | ||
expect(element).shadowDom.to.equal('bar'); | ||
}); | ||
it('renders when error is set', async function rendersOnError() { | ||
@@ -88,8 +76,3 @@ const name = 'renders-when-error-is-set'; | ||
assertType(this.errors); | ||
assertType(this.data); | ||
assertType(this.variables); | ||
assertType(this.error.message); | ||
assertType(this.data.a); | ||
// @ts-expect-error: b as number type | ||
assertType(this.data.b); | ||
if (isApolloError(this.error)) | ||
@@ -100,8 +83,2 @@ assertType(this.error.graphQLErrors); | ||
} | ||
class TDNTypeCheck extends ApolloElement { | ||
typeCheck() { | ||
assertType(this.data); | ||
assertType(this.variables); | ||
} | ||
} | ||
//# sourceMappingURL=apollo-element.test.js.map |
@@ -1,8 +0,9 @@ | ||
import type { ApolloMutationInterface, Constructor, RefetchQueriesType } from '@apollo-elements/interfaces'; | ||
import type { ApolloMutationInterface, Constructor, Data, RefetchQueriesType, Variables } from '@apollo-elements/interfaces'; | ||
import type { OperationVariables } from '@apollo/client/core'; | ||
import { ApolloElement } from './apollo-element'; | ||
declare const ApolloMutation_base: { | ||
declare const ApolloMutation_base: Constructor<ApolloElement> & { | ||
new <D_1, V_1 = Record<string, any>>(): ApolloMutationInterface<D_1, V_1>; | ||
documentType: "mutation"; | ||
} & Constructor<ApolloElement<any, any>>; | ||
observedAttributes?: string[] | undefined; | ||
}; | ||
/** | ||
@@ -17,3 +18,13 @@ * `ApolloMutation` | ||
*/ | ||
export declare class ApolloMutation<D, V = OperationVariables> extends ApolloMutation_base<D, V> implements ApolloMutationInterface<D, V> { | ||
export declare class ApolloMutation<D = unknown, V = OperationVariables> extends ApolloMutation_base<D, V> implements ApolloMutationInterface<D, V> { | ||
/** | ||
* Latest mutation data. | ||
*/ | ||
data: Data<D> | null; | ||
/** | ||
* An object that maps from the name of a variable as used in the mutation GraphQL document to that variable's value. | ||
* | ||
* @summary Mutation variables. | ||
*/ | ||
variables: Variables<D, V> | null; | ||
called: boolean; | ||
@@ -28,3 +39,5 @@ /** | ||
refetchQueries: RefetchQueriesType<D> | null; | ||
awaitRefetchQueries?: boolean; | ||
fetchPolicy?: ApolloMutationInterface<D, V>['fetchPolicy']; | ||
} | ||
export {}; |
@@ -6,8 +6,2 @@ import { __decorate } from "tslib"; | ||
import { ApolloMutationMixin } from '@apollo-elements/mixins/apollo-mutation-mixin'; | ||
const refetchQueriesConverter = { | ||
toView() { /* c8 ignore next */ return null; }, | ||
fromView(value) { | ||
return typeof value !== 'string' ? value : splitCommasAndTrim(value); | ||
}, | ||
}; | ||
/** | ||
@@ -22,5 +16,3 @@ * `ApolloMutation` | ||
*/ | ||
export class ApolloMutation | ||
// have to cast because of the TypeScript bug which causes the error in apollo-element-mixin | ||
extends ApolloMutationMixin(ApolloElement) { | ||
export class ApolloMutation extends ApolloMutationMixin(ApolloElement) { | ||
constructor() { | ||
@@ -43,4 +35,19 @@ super(...arguments); | ||
__decorate([ | ||
attr({ mode: 'fromView', attribute: 'refetch-queries', converter: refetchQueriesConverter }) | ||
attr({ | ||
mode: 'fromView', | ||
attribute: 'refetch-queries', | ||
converter: { | ||
toView() { /* c8 ignore next */ return null; }, | ||
fromView(value) { | ||
return typeof value !== 'string' ? value : splitCommasAndTrim(value); | ||
}, | ||
}, | ||
}) | ||
], ApolloMutation.prototype, "refetchQueries", void 0); | ||
__decorate([ | ||
attr({ mode: 'boolean', attribute: 'await-refetch-queries' }) | ||
], ApolloMutation.prototype, "awaitRefetchQueries", void 0); | ||
__decorate([ | ||
attr({ attribute: 'fetch-policy' }) | ||
], ApolloMutation.prototype, "fetchPolicy", void 0); | ||
//# sourceMappingURL=apollo-mutation.js.map |
import { __decorate } from "tslib"; | ||
import { setupSpies, setupStubs, } from '@apollo-elements/test-helpers'; | ||
import { fixture, expect, nextFrame, aTimeout } from '@open-wc/testing'; | ||
import { aTimeout, expect, fixture, html as fhtml, nextFrame, unsafeStatic, } from '@open-wc/testing'; | ||
import { setupClient, teardownClient, isApolloError, assertType, } from '@apollo-elements/test-helpers'; | ||
@@ -72,2 +72,14 @@ import { ApolloMutation } from './apollo-mutation'; | ||
}); | ||
it('renders when data is set', async function rendersOnData() { | ||
const name = 'renders-when-data-is-set'; | ||
const template = html `${x => { var _a, _b; return (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.foo) !== null && _b !== void 0 ? _b : 'FAIL'; }}`; | ||
let Test = class Test extends ApolloMutation { | ||
}; | ||
Test = __decorate([ | ||
customElement({ name, template }) | ||
], Test); | ||
const tag = unsafeStatic(name); | ||
const element = await fixture(fhtml `<${tag} .data="${{ foo: 'bar' }}"></${tag}>`); | ||
expect(element).shadowDom.to.equal('bar'); | ||
}); | ||
describe('refetchQueries', function () { | ||
@@ -144,2 +156,3 @@ let element; | ||
assertType(this); | ||
assertType(this); | ||
// ApolloElementInterface | ||
@@ -146,0 +159,0 @@ assertType(this.client); |
@@ -1,2 +0,2 @@ | ||
import type { ApolloQueryInterface, Constructor } from '@apollo-elements/interfaces'; | ||
import type { ApolloQueryInterface, Constructor, Data, Variables } from '@apollo-elements/interfaces'; | ||
import { ApolloElement } from './apollo-element'; | ||
@@ -7,3 +7,3 @@ import { NetworkStatus, OperationVariables } from '@apollo/client/core'; | ||
documentType: "query"; | ||
} & Constructor<ApolloElement<any, any>>; | ||
} & Constructor<ApolloElement>; | ||
/** | ||
@@ -20,4 +20,16 @@ * `ApolloQuery` | ||
export declare class ApolloQuery<D = unknown, V = OperationVariables> extends ApolloQuery_base<D, V> implements ApolloQueryInterface<D, V> { | ||
/** | ||
* Latest query data. | ||
*/ | ||
data: Data<D> | null; | ||
/** | ||
* An object that maps from the name of a variable as used in the query GraphQL document to that variable's value. | ||
* | ||
* @summary Query variables. | ||
*/ | ||
variables: Variables<D, V> | null; | ||
networkStatus: NetworkStatus; | ||
fetchPolicy?: ApolloQueryInterface<D, V>['fetchPolicy']; | ||
nextFetchPolicy?: ApolloQueryInterface<D, V>['nextFetchPolicy']; | ||
} | ||
export {}; |
@@ -16,5 +16,3 @@ import { __decorate } from "tslib"; | ||
*/ | ||
export class ApolloQuery | ||
// have to cast because of the TypeScript bug which causes the error in apollo-element-mixin | ||
extends ApolloQueryMixin(ApolloElement) { | ||
export class ApolloQuery extends ApolloQueryMixin(ApolloElement) { | ||
constructor() { | ||
@@ -28,2 +26,10 @@ super(...arguments); | ||
], ApolloQuery.prototype, "networkStatus", void 0); | ||
__decorate([ | ||
attr({ attribute: 'fetch-policy' }) | ||
], ApolloQuery.prototype, "fetchPolicy", void 0); | ||
__decorate([ | ||
attr({ | ||
attribute: 'next-fetch-policy', | ||
}) | ||
], ApolloQuery.prototype, "nextFetchPolicy", void 0); | ||
//# sourceMappingURL=apollo-query.js.map |
@@ -64,2 +64,14 @@ import { __decorate } from "tslib"; | ||
}); | ||
it('renders when data is set', async function rendersOnData() { | ||
const name = 'renders-when-data-is-set'; | ||
const template = html `${x => { var _a, _b; return (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.foo) !== null && _b !== void 0 ? _b : 'FAIL'; }}`; | ||
let Test = class Test extends ApolloQuery { | ||
}; | ||
Test = __decorate([ | ||
customElement({ name, template }) | ||
], Test); | ||
const tag = unsafeStatic(name); | ||
const element = await fixture(fhtml `<${tag} .data="${{ foo: 'bar' }}"></${tag}>`); | ||
expect(element).shadowDom.to.equal('bar'); | ||
}); | ||
}); | ||
@@ -66,0 +78,0 @@ class TypeCheck extends ApolloQuery { |
import type { OperationVariables } from '@apollo/client/core'; | ||
import type { ApolloSubscriptionInterface, Constructor, Data, Variables } from '@apollo-elements/interfaces'; | ||
import { ApolloElement } from './apollo-element'; | ||
import { ApolloSubscriptionInterface, Constructor } from '@apollo-elements/interfaces'; | ||
declare const ApolloSubscription_base: { | ||
new <D_1 = unknown, V_1 = Record<string, any>>(...a: any[]): ApolloSubscriptionInterface<D_1, V_1>; | ||
documentType: "subscription"; | ||
} & Constructor<ApolloElement<any, any>>; | ||
} & Constructor<ApolloElement>; | ||
/** | ||
@@ -19,3 +19,14 @@ * `ApolloSubscription` | ||
export declare class ApolloSubscription<D = unknown, V = OperationVariables> extends ApolloSubscription_base<D, V> implements ApolloSubscriptionInterface<D, V> { | ||
/** | ||
* Latest subscription data. | ||
*/ | ||
data: Data<D> | null; | ||
/** | ||
* An object that maps from the name of a variable as used in the subscription GraphQL document to that variable's value. | ||
* | ||
* @summary Subscription variables. | ||
*/ | ||
variables: Variables<D, V> | null; | ||
fetchPolicy: ApolloSubscriptionInterface<D, V>['fetchPolicy']; | ||
} | ||
export {}; |
@@ -0,3 +1,5 @@ | ||
import { __decorate } from "tslib"; | ||
import { ApolloElement } from './apollo-element'; | ||
import { ApolloSubscriptionMixin } from '@apollo-elements/mixins/apollo-subscription-mixin'; | ||
import { attr } from '@microsoft/fast-element'; | ||
/** | ||
@@ -13,6 +15,9 @@ * `ApolloSubscription` | ||
*/ | ||
export class ApolloSubscription | ||
// have to cast because of the TypeScript bug which causes the error in apollo-element-mixin | ||
extends ApolloSubscriptionMixin(ApolloElement) { | ||
export class ApolloSubscription extends ApolloSubscriptionMixin(ApolloElement) { | ||
} | ||
__decorate([ | ||
attr({ | ||
attribute: 'fetch-policy', | ||
}) | ||
], ApolloSubscription.prototype, "fetchPolicy", void 0); | ||
//# sourceMappingURL=apollo-subscription.js.map |
import { __decorate } from "tslib"; | ||
import { setupSpies, setupStubs } from '@apollo-elements/test-helpers'; | ||
import { fixture, expect, nextFrame, aTimeout } from '@open-wc/testing'; | ||
import { aTimeout, expect, fixture, html as fhtml, nextFrame, unsafeStatic, } from '@open-wc/testing'; | ||
import { FASTElement, customElement, DOM, html } from '@microsoft/fast-element'; | ||
@@ -61,2 +61,14 @@ import { assertType, isApolloError } from '@apollo-elements/test-helpers'; | ||
}); | ||
it('renders when data is set', async function rendersOnData() { | ||
const name = 'renders-when-data-is-set'; | ||
const template = html `${x => { var _a, _b; return (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.foo) !== null && _b !== void 0 ? _b : 'FAIL'; }}`; | ||
let Test = class Test extends ApolloSubscription { | ||
}; | ||
Test = __decorate([ | ||
customElement({ name, template }) | ||
], Test); | ||
const tag = unsafeStatic(name); | ||
const element = await fixture(fhtml `<${tag} .data="${{ foo: 'bar' }}"></${tag}>`); | ||
expect(element).shadowDom.to.equal('bar'); | ||
}); | ||
}); | ||
@@ -63,0 +75,0 @@ }); |
@@ -6,2 +6,19 @@ # Change Log | ||
# [1.3.0-alpha.0](https://github.com/apollo-elements/apollo-elements/compare/@apollo-elements/fast@1.2.3...@apollo-elements/fast@1.3.0-alpha.0) (2021-01-17) | ||
### Bug Fixes | ||
* data and variable types ([a5c919b](https://github.com/apollo-elements/apollo-elements/commit/a5c919bed9c69fd164e8ef66c54f8413c4192a1b)) | ||
### Features | ||
* add canAutoSubscribe getter ([0c336ae](https://github.com/apollo-elements/apollo-elements/commit/0c336ae995eb530fcde884bebd5ba5f18f81e4d2)) | ||
* add observed attributes ([43bf154](https://github.com/apollo-elements/apollo-elements/commit/43bf1544ecda358f4478d482f5c4cb0e1da60781)) | ||
## [1.2.3](https://github.com/apollo-elements/apollo-elements/compare/@apollo-elements/fast@1.2.2...@apollo-elements/fast@1.2.3) (2021-01-14) | ||
@@ -8,0 +25,0 @@ |
{ | ||
"name": "@apollo-elements/fast", | ||
"version": "1.2.3", | ||
"version": "1.3.0-alpha.0", | ||
"description": "👩🚀🌛 FastElements for Apollo GraphQL 🚀👨🚀", | ||
@@ -66,8 +66,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"@apollo-elements/interfaces": "^1.4.3", | ||
"@apollo-elements/mixins": "^3.4.3", | ||
"@apollo-elements/interfaces": "^1.5.0-alpha.0", | ||
"@apollo-elements/mixins": "^3.5.0-alpha.0", | ||
"@microsoft/fast-element": "^0.18.0", | ||
"tslib": "^2.0.3" | ||
}, | ||
"gitHead": "66063e0845d6f49834608050789649944950449d" | ||
"gitHead": "1e9c95d0af349d86b2bb12e600ab27494abc472b" | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
102233
824
1