apollo-angular

  • Version 4.0.1
  • Published
  • 536 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>>;

        variable gql

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

          variable graphql

          const graphql: <Result, Variables>(
          literals: string | readonly string[],
          ...placeholders: any[]
          ) => TypedDocumentNode<Result, Variables>;

            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 access to an instance of ApolloClient

                        property flags

                        protected flags?: Flags;

                          property ngZone

                          protected ngZone: NgZone;

                            method getClient

                            getClient: () => ApolloClient<TCacheShape>;
                            • Get an access to an instance of ApolloClient

                              Deprecated

                              use apollo.client instead

                            method mutate

                            mutate: <T, V = EmptyObject>(
                            options: MutationOptions<T, V>
                            ) => Observable<MutationResult<T>>;

                              method query

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

                                method setClient

                                setClient: (client: ApolloClient<TCacheShape>) => void;
                                • Set a new instance of ApolloClient Remember to clean up the store before setting a new client.

                                  Parameter client

                                  ApolloClient instance

                                  Deprecated

                                  use apollo.client = client instead

                                method subscribe

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

                                  method watchQuery

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

                                    class ApolloModule

                                    class ApolloModule {}

                                      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

                                            class Mutation<T = {}, V = EmptyObject> {}

                                              constructor

                                              constructor(apollo: Apollo);

                                                property apollo

                                                protected apollo: Apollo;

                                                  property client

                                                  client: string;

                                                    property document

                                                    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<MutationResult<T>>;

                                                            class Query

                                                            class Query<T = {}, V = EmptyObject> {}

                                                              constructor

                                                              constructor(apollo: Apollo);

                                                                property apollo

                                                                protected apollo: Apollo;

                                                                  property client

                                                                  client: string;

                                                                    property document

                                                                    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 = 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: {};

                                                                                          method fetchMore

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

                                                                                            method getCurrentResult

                                                                                            getCurrentResult: () => ApolloQueryResult<T>;

                                                                                              method getLastError

                                                                                              getLastError: () => ApolloError;

                                                                                                method getLastResult

                                                                                                getLastResult: () => ApolloQueryResult<T>;

                                                                                                  method refetch

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

                                                                                                    method resetLastResults

                                                                                                    resetLastResults: () => void;

                                                                                                      method result

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

                                                                                                        method setOptions

                                                                                                        setOptions: (opts: any) => 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

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

                                                                                                                      constructor

                                                                                                                      constructor(apollo: Apollo);

                                                                                                                        property apollo

                                                                                                                        protected apollo: Apollo;

                                                                                                                          property client

                                                                                                                          client: string;

                                                                                                                            property document

                                                                                                                            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 MutationResult

                                                                                                                                        interface MutationResult<TData = any> extends FetchResult<TData> {}

                                                                                                                                          property loading

                                                                                                                                          loading: boolean;

                                                                                                                                            interface SubscriptionResult

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

                                                                                                                                              interface WatchQueryOptions

                                                                                                                                              interface WatchQueryOptions<TVariables = 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 NamedOptions

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

                                                                                                                                                    type QueryRefFromDocument

                                                                                                                                                    type QueryRefFromDocument<T extends TypedDocumentNode> = T extends TypedDocumentNode<
                                                                                                                                                    infer R,
                                                                                                                                                    infer V
                                                                                                                                                    >
                                                                                                                                                    ? QueryRef<R, V>
                                                                                                                                                    : 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 (5)

                                                                                                                                                          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>