Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Class Mixins: ValidateVariablesMixin

Optional mixin which prevents queries from automatically subscribing until their non-nullable variables are defined.

import { ApolloQueryElement } from '@apollo-elements/interfaces';
import { ValidateVariablesMixin } from '@apollo-elements/mixins/validate-variables-mixin';
import { gql } from '@apollo/client/core';

export class ValidatedQueryElement extends ValidateVariablesMixin(ApolloQueryElement) {
  query = gql`
    query UsersByName($name: String!) {
      user { id name }
    }
  `;
}

Exports

import { ValidateVariablesMixin } from '@apollo-elements/mixins/validate-variables-mixin';

Signature

ValidateVariablesMixin

Mixin which prevents operations from fetching until their required variables are set.

Parameters

superclass

Constructor<ApolloElement>

Returns

Constructor<ApolloElement>

Methods

protected

shouldSubscribe

inherited from ApolloQueryInterface

Overrides the default shouldSubscribe predicate to prevent subscription until variables are present.

Parameters

options

Partial<SubscriptionOptions<Variables<D, V>, Data<D>>>
Property Type Description
query
DocumentNode | TypedDocumentNode
See query
variables
Variables<D, V> 
See variables
fetchPolicy
FetchPolicy
See fetchPolicy
errorPolicy
ErrorPolicy
See errorPolicy
context
Record<string, unknown>
Context object passed through the link execution chain.

Returns

boolean