File

src/app/data-dgql/queries/util.ts

Description

Generic interface for backend list parameters. This represents the actual data sent in the request, as our representation in the frontend differs slightly (see ListParams).

Index

Properties

Properties

after
after: string
Type : string
Optional
before
before: string
Type : string
Optional
filterBy
filterBy: F
Type : F
Optional
first
first: number
Type : number
Optional
last
last: number
Type : number
Optional
import {Observable} from 'rxjs';

/**
 * Apollo's GraphQL fetch method returns an Observable even though we only ever see one update
 * emitted from it.
 *
 * Hence, we just convert it to a promise here.
 *
 * @param f the observable
 * @return a promise that resolves as soon as the observable emits an update
 */
export function promisifyApolloFetch<T>(f: Observable<{data?: T}>): Promise<T> {
  return new Promise((resolve, reject) => {
    f.subscribe(
      ({data}) => resolve(data),
      (error) => reject(error)
    );
  });
}

/**
 * Generic interface for backend list parameters.
 * This represents the actual data sent in the request, as our representation in the frontend
 * differs slightly (see {@link ListParams}).
 */
export interface QueryListParams<F> {
  after?: string;
  before?: string;
  filterBy?: F;
  first?: number;
  last?: number;
}

results matching ""

    No results matching ""