Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Class Mixins: TypePoliciesMixin

Optional mixin which lets you declare type policies for a component's query.

import { ApolloQueryElement } from '@apollo-elements/interfaces';
import { TypePoliciesMixin } from '@apollo-elements/mixins/type-policies-mixin';

export class HelloQueryElement extends TypePoliciesMixin(ApolloQueryElement) {
  typePolicies = {
    Greeting: {
      fields: {
        name(next) { return next ?? 'friend'; },
        greeting(next) { return next ?? 'friend'; },
      },
    },
  }
}

Exports

import { TypePoliciesMixin } from '@apollo-elements/mixins/type-policies-mixin';

Signature

TypePoliciesMixin

Mixin which adds type policies to the Apollo cache.

Parameters

superclass

Constructor<ApolloElement>

Returns

Constructor<ApolloElement & { typePolicies: TypePolicies }>

Properties

typePolicies

TypePolicies

Type Policies added to the cache when the element connects.