Options
All
  • Public
  • Public/Protected
  • All
Menu

A lightweight GraphQL client that caches queries and mutations.

kind

class

name

GraphQL

param

Options.

param

Cache to import; usually from a server side render.

param

wrapper cacheValue

see

reportCacheErrors to setup error reporting.

example
Construct a GraphQL client. ```js import { GraphQL } from 'graphql-svelte'

const graphql = new GraphQL()

Hierarchy

  • GraphQL

Index

Constructors

Properties

Methods

Constructors

constructor

  • new GraphQL(__namedParameters?: { cache: any; cacheWrapper: any }): GraphQL
  • Parameters

    • Default value __namedParameters: { cache: any; cacheWrapper: any } = {}
      • cache: any
      • cacheWrapper: any

    Returns GraphQL

Properties

cache

Cache of loaded GraphQL operations. You probably don’t need to interact with this unless you’re implementing a server side rendering framework.

kind

member

name

GraphQL#cache

example
Export cache as JSON. ```js const exportedCache = JSON.stringify(graphql.cache) ```
example
Example cache JSON. ```json { "a1bCd2": { "data": { "viewer": { "name": "Jayden Seric" } } } } ```

cacheWrapper

cacheWrapper: Function

wrapper for cache

kind

function

name

GraphQL#cacheWrapper

example```ts

import { writable } from 'svelte/store'

this.cacheWrapper(cacheValue)

off

off: off = off

Removes an event listener.

kind

function

name

GraphQL#off

param

Event type.

param

Event handler.

on

on: on = on

Adds an event listener.

kind

function

name

GraphQL#on

param

Event type.

param

Event handler.

see

reportCacheErrors can be used with this to setup error reporting.

operations

operations: Record<GraphQLCacheKey, Promise<GraphQLCacheValue>>

A map of loading GraphQL operations. You probably don’t need to interact with this unless you’re implementing a server side rendering framework.

name

GraphQL#operations

Methods

operate

  • operate(__namedParameters: { fetchOptionsOverride: any; operation: any; reloadOnLoad: any; resetOnLoad: any }): { cacheKey: string; cacheValue: GraphQLCacheValue; cacheValuePromise: Promise<GraphQLCacheValue> }
  • Loads or reuses an already loading GraphQL operation in [GraphQL operations]{@link GraphQL#operations}. Emits a GraphQL instance fetch event if an already loading operation isn’t reused, and a cache event once it’s loaded into the [GraphQL cache]{@link GraphQL#cache}.

    kind

    function

    name

    GraphQL#operate

    Parameters

    • __namedParameters: { fetchOptionsOverride: any; operation: any; reloadOnLoad: any; resetOnLoad: any }
      • fetchOptionsOverride: any
      • operation: any
      • reloadOnLoad: any
      • resetOnLoad: any

    Returns { cacheKey: string; cacheValue: GraphQLCacheValue; cacheValuePromise: Promise<GraphQLCacheValue> }

    Loading GraphQL operation details.

reload

  • Signals that [GraphQL cache]{@link GraphQL#cache} subscribers such as the operation. Emits a GraphQL instance reload event.

    kind

    function

    name

    GraphQL#reload

    example
    Reloading the [GraphQL cache]{@link GraphQL#cache}. ```js graphql.reload() ```

    Parameters

    Returns void

reset

  • reset(exceptCacheKey: string): void
  • Resets the [GraphQL cache]{@link GraphQL#cache}, useful when a user logs out. Emits a GraphQL instance reset event.

    kind

    function

    name

    GraphQL#reset

    example
    Resetting the [GraphQL cache]{@link GraphQL#cache}. ```js graphql.reset() ```

    Parameters

    • exceptCacheKey: string

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Property

Generated using TypeDoc