apollo-angular

  • Version 8.0.0
  • Published
  • 396 kB
  • 1 dependency
  • MIT license

Install

npm i apollo-angular
yarn add apollo-angular
pnpm add apollo-angular

Overview

Use your GraphQL data in your Angular app, with the Apollo Client

Index

Variables

variable APOLLO_FLAGS

const APOLLO_FLAGS: InjectionToken<Flags>;

    variable APOLLO_NAMED_OPTIONS

    const APOLLO_NAMED_OPTIONS: InjectionToken<NamedOptions>;

      variable APOLLO_OPTIONS

      const APOLLO_OPTIONS: InjectionToken<ApolloClientOptions<any>>;

        Functions

        function gql

        gql: <Result, Variables>(
        literals: ReadonlyArray<string> | Readonly<string>,
        ...placeholders: any[]
        ) => TypedDocumentNode<Result, Variables>;

          function graphql

          graphql: <Result, Variables>(
          literals: ReadonlyArray<string> | Readonly<string>,
          ...placeholders: any[]
          ) => TypedDocumentNode<Result, Variables>;
          • Deprecated

            Instead, use import {gql as graphql} from 'apollo-angular';. Because different exports for the same thing will increase the final bundle size.

          function provideApollo

          provideApollo: <TCacheShape = any>(
          optionsFactory: () => ApolloClientOptions<TCacheShape>,
          flags?: Flags
          ) => Provider;

            function provideNamedApollo

            provideNamedApollo: (
            optionsFactory: () => NamedOptions,
            flags?: Flags
            ) => Provider;

              Classes

              class Apollo

              class Apollo extends ApolloBase<any> {}

                constructor

                constructor(
                ngZone: NgZone,
                apolloOptions?: ApolloClientOptions<any>,
                apolloNamedOptions?: NamedOptions,
                flags?: Flags
                );

                  property ɵfac

                  static ɵfac: i0.ɵɵFactoryDeclaration<
                  Apollo,
                  [null, { optional: true }, { optional: true }, { optional: true }]
                  >;

                    property ɵprov

                    static ɵprov: i0.ɵɵInjectableDeclaration<Apollo>;

                      method create

                      create: <TCacheShape>(
                      options: ApolloClientOptions<TCacheShape>,
                      name?: string
                      ) => void;
                      • Create an instance of ApolloClient

                        Parameter options

                        Options required to create ApolloClient

                        Parameter name

                        client's name

                      method createDefault

                      createDefault: <TCacheShape>(options: ApolloClientOptions<TCacheShape>) => void;
                      • Create a default ApolloClient, same as apollo.create(options)

                        Parameter options

                        ApolloClient's options

                      method createNamed

                      createNamed: <TCacheShape>(
                      name: string,
                      options: ApolloClientOptions<TCacheShape>
                      ) => void;
                      • Create a named ApolloClient, same as apollo.create(options, name)

                        Parameter name

                        client's name

                        Parameter options

                        ApolloClient's options

                      method default

                      default: () => ApolloBase<any>;
                      • Use a default ApolloClient

                      method removeClient

                      removeClient: (name?: string) => void;
                      • Remember to clean up the store before removing a client

                        Parameter name

                        client's name

                      method use

                      use: (name: string) => ApolloBase<any>;
                      • Use a named ApolloClient

                        Parameter name

                        client's name

                      class ApolloBase

                      class ApolloBase<TCacheShape = any> {}

                        constructor

                        constructor(ngZone: NgZone, flags?: Flags, _client?: ApolloClient<TCacheShape>);

                          property client

                          client: ApolloClient<TCacheShape>;
                          • Get an instance of ApolloClient

                          property flags

                          protected readonly flags?: Flags;

                            property ngZone

                            protected readonly ngZone: NgZone;

                              method mutate

                              mutate: <T, V extends OperationVariables = EmptyObject>(
                              options: MutationOptions<T, V>
                              ) => Observable<any>;

                                method query

                                query: <T, V extends OperationVariables = EmptyObject>(
                                options: QueryOptions<V, T>
                                ) => Observable<ApolloQueryResult<T>>;

                                  method subscribe

                                  subscribe: <T, V extends OperationVariables = EmptyObject>(
                                  options: SubscriptionOptions<V, T>,
                                  extra?: ExtraSubscriptionOptions
                                  ) => Observable<FetchResult<T>>;

                                    method watchFragment

                                    watchFragment: <
                                    TFragmentData = unknown,
                                    TVariables extends OperationVariables = EmptyObject
                                    >(
                                    options: WatchFragmentOptions<TFragmentData, TVariables>,
                                    extra?: ExtraSubscriptionOptions
                                    ) => Observable<WatchFragmentResult<TFragmentData>>;

                                      method watchQuery

                                      watchQuery: <TData, TVariables extends OperationVariables = EmptyObject>(
                                      options: WatchQueryOptions<TVariables, TData>
                                      ) => QueryRef<TData, TVariables>;

                                        class ApolloModule

                                        class ApolloModule {}
                                        • This is deprecated and will be removed in the next major version, because Angular is moving toward a moduleless ecosystem.

                                          Instead, use either provideApollo() or provideNamedApollo().

                                          Deprecated

                                        property ɵfac

                                        static ɵfac: i0.ɵɵFactoryDeclaration<ApolloModule, never>;

                                          property ɵinj

                                          static ɵinj: i0.ɵɵInjectorDeclaration<ApolloModule>;

                                            property ɵmod

                                            static ɵmod: i0.ɵɵNgModuleDeclaration<ApolloModule, never, never, never>;

                                              class Mutation

                                              abstract class Mutation<T = {}, V extends OperationVariables = EmptyObject> {}

                                                constructor

                                                constructor(apollo: Apollo);

                                                  property apollo

                                                  protected readonly apollo: Apollo;

                                                    property client

                                                    client: string;

                                                      property document

                                                      abstract readonly document: any;

                                                        property ɵfac

                                                        static ɵfac: i0.ɵɵFactoryDeclaration<Mutation<any, any>, never>;

                                                          property ɵprov

                                                          static ɵprov: i0.ɵɵInjectableDeclaration<Mutation<any, any>>;

                                                            method mutate

                                                            mutate: (variables?: V, options?: MutationOptionsAlone<T, V>) => Observable<any>;

                                                              class Query

                                                              abstract class Query<T = {}, V extends OperationVariables = EmptyObject> {}

                                                                constructor

                                                                constructor(apollo: Apollo);

                                                                  property apollo

                                                                  protected readonly apollo: Apollo;

                                                                    property client

                                                                    client: string;

                                                                      property document

                                                                      abstract readonly document: any;

                                                                        property ɵfac

                                                                        static ɵfac: i0.ɵɵFactoryDeclaration<Query<any, any>, never>;

                                                                          property ɵprov

                                                                          static ɵprov: i0.ɵɵInjectableDeclaration<Query<any, any>>;

                                                                            method fetch

                                                                            fetch: (
                                                                            variables?: V,
                                                                            options?: QueryOptionsAlone<V, T>
                                                                            ) => Observable<ApolloQueryResult<T>>;

                                                                              method watch

                                                                              watch: (variables?: V, options?: WatchQueryOptionsAlone<V, T>) => QueryRef<T, V>;

                                                                                class QueryRef

                                                                                class QueryRef<T, V extends OperationVariables = EmptyObject> {}

                                                                                  constructor

                                                                                  constructor(
                                                                                  obsQuery: ObservableQuery<T, V>,
                                                                                  ngZone: NgZone,
                                                                                  options: WatchQueryOptions<V, T>
                                                                                  );

                                                                                    property options

                                                                                    readonly options: any;

                                                                                      property queryId

                                                                                      queryId: ObservableQuery<T, V>;

                                                                                        property valueChanges

                                                                                        valueChanges: Observable<ApolloQueryResult<T>>;

                                                                                          property variables

                                                                                          readonly variables: OperationVariables;

                                                                                            method fetchMore

                                                                                            fetchMore: <K = V>(
                                                                                            fetchMoreOptions: FetchMoreQueryOptions<K, T>
                                                                                            ) => Promise<ApolloQueryResult<T>>;

                                                                                              method getCurrentResult

                                                                                              getCurrentResult: () => ApolloQueryResult<T>;

                                                                                                method getLastError

                                                                                                getLastError: () => ApolloError | undefined;

                                                                                                  method getLastResult

                                                                                                  getLastResult: () => ApolloQueryResult<T> | undefined;

                                                                                                    method refetch

                                                                                                    refetch: (variables?: V) => Promise<ApolloQueryResult<T>>;

                                                                                                      method resetLastResults

                                                                                                      resetLastResults: () => void;

                                                                                                        method result

                                                                                                        result: () => Promise<ApolloQueryResult<T>>;

                                                                                                          method setOptions

                                                                                                          setOptions: (
                                                                                                          opts: Partial<WatchQueryOptions<V, T>>
                                                                                                          ) => Promise<ApolloQueryResult<T>>;

                                                                                                            method setVariables

                                                                                                            setVariables: (variables: V) => Promise<void | ApolloQueryResult<T>>;

                                                                                                              method startPolling

                                                                                                              startPolling: (pollInterval: number) => void;

                                                                                                                method stopPolling

                                                                                                                stopPolling: () => void;

                                                                                                                  method subscribeToMore

                                                                                                                  subscribeToMore: <MT = any, MV = EmptyObject>(
                                                                                                                  options: SubscribeToMoreOptions<T, MV, MT>
                                                                                                                  ) => () => void;

                                                                                                                    method updateQuery

                                                                                                                    updateQuery: (
                                                                                                                    mapFn: (previousQueryResult: T, options: UpdateQueryOptions<V>) => T
                                                                                                                    ) => void;

                                                                                                                      class Subscription

                                                                                                                      abstract class Subscription<T = any, V extends OperationVariables = EmptyObject> {}

                                                                                                                        constructor

                                                                                                                        constructor(apollo: Apollo);

                                                                                                                          property apollo

                                                                                                                          protected readonly apollo: Apollo;

                                                                                                                            property client

                                                                                                                            client: string;

                                                                                                                              property document

                                                                                                                              abstract readonly document: any;

                                                                                                                                property ɵfac

                                                                                                                                static ɵfac: i0.ɵɵFactoryDeclaration<Subscription<any, any>, never>;

                                                                                                                                  property ɵprov

                                                                                                                                  static ɵprov: i0.ɵɵInjectableDeclaration<Subscription<any, any>>;

                                                                                                                                    method subscribe

                                                                                                                                    subscribe: (
                                                                                                                                    variables?: V,
                                                                                                                                    options?: SubscriptionOptionsAlone<V, T>,
                                                                                                                                    extra?: ExtraSubscriptionOptions
                                                                                                                                    ) => Observable<SubscriptionResult<T>>;

                                                                                                                                      Interfaces

                                                                                                                                      interface ExtraSubscriptionOptions

                                                                                                                                      interface ExtraSubscriptionOptions {}

                                                                                                                                        property useZone

                                                                                                                                        useZone?: boolean;

                                                                                                                                          interface SubscriptionResult

                                                                                                                                          interface SubscriptionResult<TData> extends ExecutionResult<TData> {}

                                                                                                                                            interface WatchQueryOptions

                                                                                                                                            interface WatchQueryOptions<
                                                                                                                                            TVariables extends OperationVariables = EmptyObject,
                                                                                                                                            TData = any
                                                                                                                                            > extends CoreWatchQueryOptions<TVariables, TData> {}

                                                                                                                                              property useInitialLoading

                                                                                                                                              useInitialLoading?: boolean;
                                                                                                                                              • Observable starts with { loading: true }. There's a big chance the next major version will enable that by default.

                                                                                                                                                Disabled by default

                                                                                                                                              Type Aliases

                                                                                                                                              type Flags

                                                                                                                                              type Flags = {
                                                                                                                                              /**
                                                                                                                                              * Observable starts with `{ loading: true }`.
                                                                                                                                              * There's a big chance the next major version will enable that by default.
                                                                                                                                              *
                                                                                                                                              * Disabled by default
                                                                                                                                              */
                                                                                                                                              useInitialLoading?: boolean;
                                                                                                                                              /**
                                                                                                                                              * Observable starts with `{ loading: true }`.
                                                                                                                                              *
                                                                                                                                              * Disabled by default
                                                                                                                                              */
                                                                                                                                              useMutationLoading?: boolean;
                                                                                                                                              };

                                                                                                                                                type MutationResult

                                                                                                                                                type MutationResult<TData = any> = FetchResult<TData> & {
                                                                                                                                                loading?: boolean;
                                                                                                                                                };

                                                                                                                                                  type NamedOptions

                                                                                                                                                  type NamedOptions = Record<string, ApolloClientOptions<any>>;

                                                                                                                                                    type QueryRefFromDocument

                                                                                                                                                    type QueryRefFromDocument<T extends TypedDocumentNode> = T extends TypedDocumentNode<
                                                                                                                                                    infer R,
                                                                                                                                                    infer V
                                                                                                                                                    >
                                                                                                                                                    ? QueryRef<R, V & OperationVariables>
                                                                                                                                                    : never;

                                                                                                                                                      type ResultOf

                                                                                                                                                      type ResultOf<T extends TypedDocumentNode> = T extends TypedDocumentNode<infer R>
                                                                                                                                                      ? R
                                                                                                                                                      : never;

                                                                                                                                                        type VariablesOf

                                                                                                                                                        type VariablesOf<T extends TypedDocumentNode> = T extends TypedDocumentNode<
                                                                                                                                                        any,
                                                                                                                                                        infer V
                                                                                                                                                        >
                                                                                                                                                        ? V
                                                                                                                                                        : never;

                                                                                                                                                          Package Files (10)

                                                                                                                                                          Dependencies (1)

                                                                                                                                                          Dev Dependencies (0)

                                                                                                                                                          No dev dependencies.

                                                                                                                                                          Peer Dependencies (4)

                                                                                                                                                          Badge

                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/apollo-angular.

                                                                                                                                                          • Markdown
                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/apollo-angular)
                                                                                                                                                          • HTML
                                                                                                                                                            <a href="https://www.jsdocs.io/package/apollo-angular"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>