apollo-angular-signal 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -150,6 +150,91 @@ export class MessagesComponent {
150
150
  }
151
151
  ```
152
152
 
153
+ ### Using the GqlSignalStatus Component
154
+
155
+ The `GqlSignalStatus` component simplifies handling loading and error states with a declarative approach:
156
+
157
+ ```typescript
158
+ import { Component, inject } from '@angular/core';
159
+ import { Apollo, gql } from 'apollo-angular';
160
+ import { gqlQuery, GqlSignalStatus } from 'apollo-angular-signal';
161
+
162
+ const GET_USERS = gql`
163
+ query GetUsers {
164
+ users {
165
+ id
166
+ name
167
+ email
168
+ }
169
+ }
170
+ `;
171
+
172
+ @Component({
173
+ selector: 'app-users',
174
+ imports: [GqlSignalStatus],
175
+ template: `
176
+ <gql-signal-status [gql]="users()">
177
+ <div gqlLoading>Loading users...</div>
178
+ <div gqlError>Failed to load users</div>
179
+
180
+ <ul>
181
+ @for (user of users().data?.users; track user.id) {
182
+ <li>{{ user.name }} - {{ user.email }}</li>
183
+ }
184
+ </ul>
185
+ </gql-signal-status>
186
+ `
187
+ })
188
+ export class UsersComponent {
189
+ private apollo = inject(Apollo);
190
+
191
+ users = gqlQuery<{ users: Array<{ id: string; name: string; email: string }> }>(
192
+ this.apollo.watchQuery({
193
+ query: GET_USERS
194
+ }).valueChanges
195
+ );
196
+ }
197
+ ```
198
+
199
+ **Features:**
200
+ - Automatically shows loading state while query is in progress
201
+ - Displays error state if query fails
202
+ - Renders main content when data is available
203
+ - Supports custom loading and error templates via `gqlLoading` and `gqlError` attributes
204
+ - Falls back to global defaults if no custom templates provided
205
+
206
+ ### Global Configuration
207
+
208
+ You can configure default loading and error templates globally:
209
+
210
+ ```typescript
211
+ import { ApplicationConfig } from '@angular/core';
212
+ import { provideGqlSignalConfig } from 'apollo-angular-signal';
213
+
214
+ // With string templates
215
+ export const appConfig: ApplicationConfig = {
216
+ providers: [
217
+ provideGqlSignalConfig({
218
+ loadingDefaultTemplate: 'Loading...',
219
+ errorDefaultTemplate: 'An error occurred'
220
+ })
221
+ ]
222
+ };
223
+
224
+ // Or with component templates
225
+ import { LoadingSpinnerComponent } from './loading-spinner.component';
226
+ import { ErrorMessageComponent } from './error-message.component';
227
+
228
+ export const appConfig: ApplicationConfig = {
229
+ providers: [
230
+ provideGqlSignalConfig({
231
+ loadingDefaultTemplate: LoadingSpinnerComponent,
232
+ errorDefaultTemplate: ErrorMessageComponent
233
+ })
234
+ ]
235
+ };
236
+ ```
237
+
153
238
  ## API
154
239
 
155
240
  ### `gqlQuery<T>(query)`
@@ -1,69 +1,101 @@
1
- import { signal, computed, effect } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, input, ViewEncapsulation, ChangeDetectionStrategy, Component, signal, computed, effect } from '@angular/core';
3
+ import { NgComponentOutlet } from '@angular/common';
2
4
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
+ import { debounce } from 'es-toolkit';
6
+
7
+ const GqlLibConfigToken = new InjectionToken('GqlLibConfig');
8
+ function provideGqlSignalConfig(config) {
9
+ return {
10
+ provide: GqlLibConfigToken,
11
+ useValue: config,
12
+ };
13
+ }
14
+
15
+ class GqlSignalStatus {
16
+ config = inject(GqlLibConfigToken, {
17
+ optional: true,
18
+ });
19
+ gql = input.required(...(ngDevMode ? [{ debugName: "gql" }] : []));
20
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: GqlSignalStatus, deps: [], target: i0.ɵɵFactoryTarget.Component });
21
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: GqlSignalStatus, isStandalone: true, selector: "gql-signal-status", inputs: { gql: { classPropertyName: "gql", publicName: "gql", isSignal: true, isRequired: true, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: "@if (gql().loading) {\r\n <ng-content select=\"[gqlLoading]\">\r\n @if (config != null && config.loadingDefaultTemplate) {\r\n @if (typeof config.loadingDefaultTemplate === 'string') {\r\n {{ config.loadingDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.loadingDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else if (gql().hasError) {\r\n <ng-content select=\"[gqlError]\">\r\n @if (config != null && config.errorDefaultTemplate) {\r\n @if (typeof config.errorDefaultTemplate === 'string') {\r\n {{ config.errorDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.errorDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else {\r\n <ng-content/>\r\n}\r\n", dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
22
+ }
23
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: GqlSignalStatus, decorators: [{
24
+ type: Component,
25
+ args: [{ selector: 'gql-signal-status', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
26
+ style: 'display: contents',
27
+ }, imports: [NgComponentOutlet], template: "@if (gql().loading) {\r\n <ng-content select=\"[gqlLoading]\">\r\n @if (config != null && config.loadingDefaultTemplate) {\r\n @if (typeof config.loadingDefaultTemplate === 'string') {\r\n {{ config.loadingDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.loadingDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else if (gql().hasError) {\r\n <ng-content select=\"[gqlError]\">\r\n @if (config != null && config.errorDefaultTemplate) {\r\n @if (typeof config.errorDefaultTemplate === 'string') {\r\n {{ config.errorDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.errorDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else {\r\n <ng-content/>\r\n}\r\n" }]
28
+ }], propDecorators: { gql: [{ type: i0.Input, args: [{ isSignal: true, alias: "gql", required: true }] }] } });
3
29
 
4
30
  function gqlQuery(query) {
5
31
  if (typeof query === 'function') {
6
32
  return gqlAsync(query);
7
33
  }
8
34
  else {
9
- const state = signal({
10
- loading: true,
11
- hasError: false,
12
- }, ...(ngDevMode ? [{ debugName: "state" }] : []));
35
+ const state = signal(getInitialState(), ...(ngDevMode ? [{ debugName: "state" }] : []));
13
36
  query.pipe(takeUntilDestroyed()).subscribe({
14
37
  next: (res) => {
15
- state.set({
16
- data: res.data,
17
- hasError: !!res.error,
18
- error: res.error,
19
- loading: 'loading' in res ? res.loading : false,
20
- });
38
+ processRes(state, res);
21
39
  },
22
40
  error: (error) => {
23
- state.set({
24
- loading: false,
25
- hasError: true,
26
- error,
27
- });
41
+ processErr(state, error);
28
42
  },
29
43
  });
30
44
  return state;
31
45
  }
32
46
  }
33
47
  function gqlAsync(fn) {
34
- const state = signal({
35
- loading: true,
36
- hasError: false,
37
- }, ...(ngDevMode ? [{ debugName: "state" }] : []));
48
+ const state = signal(getInitialState(), ...(ngDevMode ? [{ debugName: "state" }] : []));
38
49
  const source$ = computed(fn, ...(ngDevMode ? [{ debugName: "source$" }] : []));
50
+ let sub;
51
+ // Use debounce to ensure we only subscribe once when multiple dependent signals
52
+ // update synchronously, avoiding unnecessary subscription churn
53
+ const subscribeOnObservable = debounce((observable) => {
54
+ sub = observable.subscribe({
55
+ next: (res) => {
56
+ processRes(state, res);
57
+ },
58
+ error(error) {
59
+ processErr(state, error);
60
+ },
61
+ });
62
+ }, 0);
39
63
  effect((onCleanup) => {
40
64
  const observable = source$();
41
- let sub;
42
65
  if (observable) {
43
- sub = observable.subscribe({
44
- next: (res) => {
45
- state.set({
46
- data: res.data,
47
- loading: 'loading' in res ? res.loading : false,
48
- hasError: !!res.error,
49
- error: res.error,
50
- });
51
- },
52
- error: (error) => {
53
- state.set({
54
- loading: false,
55
- hasError: true,
56
- error,
57
- });
58
- },
59
- });
66
+ subscribeOnObservable(observable);
67
+ }
68
+ else {
69
+ state.set(getInitialState());
60
70
  }
61
71
  onCleanup(() => {
62
72
  sub?.unsubscribe();
73
+ sub = null;
63
74
  });
64
75
  });
65
76
  return state;
66
77
  }
78
+ function processRes(state, res) {
79
+ state.set({
80
+ data: res.data,
81
+ loading: 'loading' in res ? res.loading : false,
82
+ hasError: !!res.error,
83
+ error: res.error,
84
+ });
85
+ }
86
+ function processErr(state, error) {
87
+ state.set({
88
+ loading: false,
89
+ hasError: true,
90
+ error,
91
+ });
92
+ }
93
+ function getInitialState() {
94
+ return {
95
+ loading: true,
96
+ hasError: false,
97
+ };
98
+ }
67
99
 
68
100
  /*
69
101
  * Public API Surface of apollo-angular-signal
@@ -73,5 +105,5 @@ function gqlAsync(fn) {
73
105
  * Generated bundle index. Do not edit.
74
106
  */
75
107
 
76
- export { gqlQuery };
108
+ export { GqlSignalStatus, gqlQuery, provideGqlSignalConfig };
77
109
  //# sourceMappingURL=apollo-angular-signal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-angular-signal.mjs","sources":["../../../projects/apollo-angular-signal/src/lib/apollo-angular-signal.ts","../../../projects/apollo-angular-signal/src/public-api.ts","../../../projects/apollo-angular-signal/src/apollo-angular-signal.ts"],"sourcesContent":["import { computed, effect, signal, type Signal } from '@angular/core';\nimport type { ObservableQuery } from '@apollo/client';\nimport type { Apollo } from 'apollo-angular';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { Subscription, Observable } from 'rxjs';\n\nexport type GqlQueryResult<T> =\n | Apollo.QueryResult<T>\n | Apollo.SubscribeResult<T>\n | ObservableQuery.Result<T>;\n\nexport type ObservableResult<T> = Observable<GqlQueryResult<T>>;\n\ntype Maybe<T> = T | null | undefined;\n\nexport interface GqlSignalResult<T> {\n data?: T;\n loading: boolean;\n hasError: boolean;\n error?: unknown;\n}\n\nexport function gqlQuery<T>(\n query: ObservableResult<T> | (() => Maybe<ObservableResult<T>>),\n): Signal<GqlSignalResult<T>> {\n if (typeof query === 'function') {\n return gqlAsync(query);\n } else {\n const state = signal<GqlSignalResult<T>>({\n loading: true,\n hasError: false,\n });\n\n query.pipe(takeUntilDestroyed()).subscribe({\n next: (res) => {\n state.set({\n data: res.data as T,\n hasError: !!res.error,\n error: res.error,\n loading: 'loading' in res ? res.loading : false,\n });\n },\n error: (error: unknown) => {\n state.set({\n loading: false,\n hasError: true,\n error,\n });\n },\n });\n\n return state;\n }\n}\n\nfunction gqlAsync<T>(\n fn: () => Maybe<ObservableResult<T>>,\n): Signal<GqlSignalResult<T>> {\n const state = signal<GqlSignalResult<T>>({\n loading: true,\n hasError: false,\n });\n\n const source$ = computed(fn);\n\n effect((onCleanup) => {\n const observable = source$();\n let sub: Maybe<Subscription>;\n if (observable) {\n sub = observable.subscribe({\n next: (res) => {\n state.set({\n data: res.data as T,\n loading: 'loading' in res ? res.loading : false,\n hasError: !!res.error,\n error: res.error,\n });\n },\n error: (error: unknown) => {\n state.set({\n loading: false,\n hasError: true,\n error,\n });\n },\n });\n }\n\n onCleanup(() => {\n sub?.unsubscribe();\n });\n });\n\n return state;\n}\n","/*\n * Public API Surface of apollo-angular-signal\n */\n\nexport * from './lib/apollo-angular-signal';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAsBM,SAAU,QAAQ,CACtB,KAA+D,EAAA;AAE/D,IAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,QAAA,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB;SAAO;QACL,MAAM,KAAK,GAAG,MAAM,CAAqB;AACvC,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,QAAQ,EAAE,KAAK;AAChB,SAAA,EAAA,IAAA,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G,CAAC;wBACR,IAAI,EAAE,GAAG,CAAC,IAAS;AACnB,wBAAA,OAAO,EAAE,SAAS,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,GAAG,KAAK;AAC/C,wBAAA,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK;wBACrB,KAAK,EAAE,GAAG,CAAC,KAAK;AACjB,qBAAA,CAAC;gBACJ,CAAC;AACD,gBAAA,KAAK,EAAE,CAAC,KAAc,KAAI;oBACxB,KAAK,CAAC,GAAG,CAAC;AACR,wBAAA,OAAO,EAAE,KAAK;AACd,wBAAA,QAAQ,EAAE,IAAI;wBACd,KAAK;AACN,qBAAA,CAAC;gBACJ,CAAC;AACF,aAAA,CAAC;QACJ;QAEA,SAAS,CAAC,MAAK;YACb,GAAG,EAAE,WAAW,EAAE;AACpB,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,KAAK;AACd;;AC9FA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"apollo-angular-signal.mjs","sources":["../../../projects/apollo-angular-signal/src/lib/config.ts","../../../projects/apollo-angular-signal/src/lib/gql-signal-status/gql-signal-status.ts","../../../projects/apollo-angular-signal/src/lib/gql-signal-status/gql-signal-status.html","../../../projects/apollo-angular-signal/src/lib/apollo-angular-signal.ts","../../../projects/apollo-angular-signal/src/public-api.ts","../../../projects/apollo-angular-signal/src/apollo-angular-signal.ts"],"sourcesContent":["import { InjectionToken, Provider, Type } from '@angular/core';\n\nexport interface GqlLibConfig {\n errorDefaultTemplate?: string | Type<unknown>;\n loadingDefaultTemplate?: string | Type<unknown>;\n}\n\nexport const GqlLibConfigToken = new InjectionToken<GqlLibConfig>(\n 'GqlLibConfig',\n);\n\nexport function provideGqlSignalConfig(config: GqlLibConfig): Provider {\n return {\n provide: GqlLibConfigToken,\n useValue: config,\n };\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n inject,\n input,\n ViewEncapsulation,\n} from '@angular/core';\nimport { GqlSignalResult } from '../apollo-angular-signal';\nimport { GqlLibConfigToken } from '../config';\nimport { NgComponentOutlet } from '@angular/common';\n\n@Component({\n selector: 'gql-signal-status',\n templateUrl: './gql-signal-status.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n style: 'display: contents',\n },\n imports: [NgComponentOutlet],\n})\nexport class GqlSignalStatus<T> {\n protected readonly config = inject(GqlLibConfigToken, {\n optional: true,\n });\n\n readonly gql = input.required<GqlSignalResult<T>>();\n}\n","@if (gql().loading) {\r\n <ng-content select=\"[gqlLoading]\">\r\n @if (config != null && config.loadingDefaultTemplate) {\r\n @if (typeof config.loadingDefaultTemplate === 'string') {\r\n {{ config.loadingDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.loadingDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else if (gql().hasError) {\r\n <ng-content select=\"[gqlError]\">\r\n @if (config != null && config.errorDefaultTemplate) {\r\n @if (typeof config.errorDefaultTemplate === 'string') {\r\n {{ config.errorDefaultTemplate }}\r\n } @else {\r\n <ng-container *ngComponentOutlet=\"config.errorDefaultTemplate\" />\r\n }\r\n }\r\n </ng-content>\r\n} @else {\r\n <ng-content/>\r\n}\r\n","import {\n computed,\n effect,\n signal,\n type Signal,\n type WritableSignal,\n} from '@angular/core';\nimport type { ObservableQuery } from '@apollo/client';\nimport type { Apollo } from 'apollo-angular';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { Subscription, Observable } from 'rxjs';\nimport { debounce } from 'es-toolkit';\n\nexport type GqlQueryResult<T> =\n | Apollo.QueryResult<T>\n | Apollo.SubscribeResult<T>\n | ObservableQuery.Result<T>;\n\ntype ObservableResult<T> = Observable<GqlQueryResult<T>>;\n\ntype Maybe<T> = T | null | undefined;\n\nexport interface GqlSignalResult<T> {\n data?: T;\n loading: boolean;\n hasError: boolean;\n error?: unknown;\n}\n\nexport function gqlQuery<T>(\n query: ObservableResult<T> | (() => Maybe<ObservableResult<T>>),\n): Signal<GqlSignalResult<T>> {\n if (typeof query === 'function') {\n return gqlAsync(query);\n } else {\n const state = signal<GqlSignalResult<T>>(getInitialState());\n\n query.pipe(takeUntilDestroyed()).subscribe({\n next: (res) => {\n processRes(state, res);\n },\n error: (error: unknown) => {\n processErr(state, error);\n },\n });\n\n return state;\n }\n}\n\nfunction gqlAsync<T>(\n fn: () => Maybe<ObservableResult<T>>,\n): Signal<GqlSignalResult<T>> {\n const state = signal<GqlSignalResult<T>>(getInitialState());\n\n const source$ = computed(fn);\n\n let sub: Maybe<Subscription>;\n\n // Use debounce to ensure we only subscribe once when multiple dependent signals\n // update synchronously, avoiding unnecessary subscription churn\n const subscribeOnObservable = debounce((observable: ObservableResult<T>) => {\n sub = observable.subscribe({\n next: (res) => {\n processRes(state, res);\n },\n error(error: unknown) {\n processErr(state, error);\n },\n });\n }, 0);\n\n effect((onCleanup) => {\n const observable = source$();\n if (observable) {\n subscribeOnObservable(observable);\n } else {\n state.set(getInitialState());\n }\n\n onCleanup(() => {\n sub?.unsubscribe();\n sub = null;\n });\n });\n\n return state;\n}\n\nfunction processRes<T>(\n state: WritableSignal<GqlSignalResult<T>>,\n res: GqlQueryResult<T>,\n): void {\n state.set({\n data: res.data as T,\n loading: 'loading' in res ? res.loading : false,\n hasError: !!res.error,\n error: res.error,\n });\n}\n\nfunction processErr<T>(\n state: WritableSignal<GqlSignalResult<T>>,\n error: unknown,\n): void {\n state.set({\n loading: false,\n hasError: true,\n error,\n });\n}\n\nfunction getInitialState<T>(): GqlSignalResult<T> {\n return {\n loading: true,\n hasError: false,\n };\n}\n","/*\n * Public API Surface of apollo-angular-signal\n */\n\nexport { GqlSignalStatus } from './lib/gql-signal-status/gql-signal-status';\nexport * from './lib/apollo-angular-signal';\nexport { provideGqlSignalConfig, type GqlLibConfig } from './lib/config';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";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SAAA,CAAC;IACJ,CAAC,EAAE,CAAC,CAAC;AAEL,IAAA,MAAM,CAAC,CAAC,SAAS,KAAI;AACnB,QAAA,MAAM,UAAU,GAAG,OAAO,EAAE;QAC5B,IAAI,UAAU,EAAE;YACd,qBAAqB,CAAC,UAAU,CAAC;QACnC;aAAO;AACL,YAAA,KAAK,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QAC9B;QAEA,SAAS,CAAC,MAAK;YACb,GAAG,EAAE,WAAW,EAAE;YAClB,GAAG,GAAG,IAAI;AACZ,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,UAAU,CACjB,KAAyC,EACzC,GAAsB,EAAA;IAEtB,KAAK,CAAC,GAAG,CAAC;QACR,IAAI,EAAE,GAAG,CAAC,IAAS;AACnB,QAAA,OAAO,EAAE,SAAS,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,GAAG,KAAK;AAC/C,QAAA,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK;QACrB,KAAK,EAAE,GAAG,CAAC,KAAK;AACjB,KAAA,CAAC;AACJ;AAEA,SAAS,UAAU,CACjB,KAAyC,EACzC,KAAc,EAAA;IAEd,KAAK,CAAC,GAAG,CAAC;AACR,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,QAAQ,EAAE,IAAI;QACd,KAAK;AACN,KAAA,CAAC;AACJ;AAEA,SAAS,eAAe,GAAA;IACtB,OAAO;AACL,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,QAAQ,EAAE,KAAK;KAChB;AACH;;ACrHA;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "apollo-angular-signal",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20 || ^21",
6
6
  "@angular/core": "^20 || ^21",
7
7
  "apollo-angular": "^13",
8
8
  "@apollo/client": "^4",
9
- "rxjs": "^7"
9
+ "rxjs": "^7",
10
+ "es-toolkit": "^1.40 || ^2"
10
11
  },
11
12
  "sideEffects": false,
12
13
  "module": "fesm2022/apollo-angular-signal.mjs",
@@ -23,4 +24,4 @@
23
24
  "dependencies": {
24
25
  "tslib": "^2.3.0"
25
26
  }
26
- }
27
+ }
@@ -1,4 +1,6 @@
1
- import { Signal } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { Signal, Type, Provider } from '@angular/core';
3
+ import * as apollo_angular_signal from 'apollo-angular-signal';
2
4
  import { ObservableQuery } from '@apollo/client';
3
5
  import { Apollo } from 'apollo-angular';
4
6
  import { Observable } from 'rxjs';
@@ -14,5 +16,18 @@ interface GqlSignalResult<T> {
14
16
  }
15
17
  declare function gqlQuery<T>(query: ObservableResult<T> | (() => Maybe<ObservableResult<T>>)): Signal<GqlSignalResult<T>>;
16
18
 
17
- export { gqlQuery };
18
- export type { GqlQueryResult, GqlSignalResult, ObservableResult };
19
+ declare class GqlSignalStatus<T> {
20
+ protected readonly config: apollo_angular_signal.GqlLibConfig | null;
21
+ readonly gql: i0.InputSignal<GqlSignalResult<T>>;
22
+ static ɵfac: i0.ɵɵFactoryDeclaration<GqlSignalStatus<any>, never>;
23
+ static ɵcmp: i0.ɵɵComponentDeclaration<GqlSignalStatus<any>, "gql-signal-status", never, { "gql": { "alias": "gql"; "required": true; "isSignal": true; }; }, {}, never, ["[gqlLoading]", "[gqlError]", "*"], true, never>;
24
+ }
25
+
26
+ interface GqlLibConfig {
27
+ errorDefaultTemplate?: string | Type<unknown>;
28
+ loadingDefaultTemplate?: string | Type<unknown>;
29
+ }
30
+ declare function provideGqlSignalConfig(config: GqlLibConfig): Provider;
31
+
32
+ export { GqlSignalStatus, gqlQuery, provideGqlSignalConfig };
33
+ export type { GqlLibConfig, GqlQueryResult, GqlSignalResult };