Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kamilkisiela/apollo-angular
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: apollo-angular@8.0.2
Choose a base ref
...
head repository: kamilkisiela/apollo-angular
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: apollo-angular@9.0.0
Choose a head ref
  • 5 commits
  • 11 files changed
  • 2 contributors

Commits on Feb 17, 2025

  1. Use working API endpoint

    PowerKiKi committed Feb 17, 2025
    Copy the full SHA
    49fc004 View commit details
  2. BREAKING Requires @apollo/client 3.13.1

    - Requires `@apollo/client` 3.13.1
    - Dropped `SubscriptionResult`, because it added extra maintenance work to
    keep native types in sync, and it brought no value over using native
    type.
        ```diff
        - import type { SubscriptionResult } from 'apollo-angular';
        + import type { FetchResult } from '@apollo/client/core';
        ```
    - Most methods of `QueryRef` forward types from `@apollo/client`. That
    should allow always using correct types from whichever `@apollo/client`
    version is installed without needing to touch `apollo-angular`.
    - `QueryRef.valueChanges` and `QueryRef.queryId` are readonly, because
    there is no reason for those to be re-affected.
    PowerKiKi committed Feb 17, 2025
    Copy the full SHA
    6d3d5ba View commit details
  3. Copy the full SHA
    88656f0 View commit details
  4. Don't sync labels

    The Guild has a list of common labels, declared in https://github
    .com/the-guild-org/shared-resources. However, we pretty much never use
    any of those, so they are, in fact, noise that makes it harder to choose
    the correct labels with pre-existing almost-duplicate labels.
    PowerKiKi committed Feb 17, 2025
    Copy the full SHA
    58a9c56 View commit details

Commits on Feb 18, 2025

  1. chore(release): update monorepo packages versions

    github-actions[bot] authored and PowerKiKi committed Feb 18, 2025
    Copy the full SHA
    f86e55d View commit details
51 changes: 0 additions & 51 deletions .github/labels.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/github.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/platform-server": "^18.0.0",
"@angular/router": "^18.0.0",
"@apollo/client": "^3.10.4",
"@apollo/client": "^3.13.1",
"@babel/core": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@changesets/changelog-github": "^0.5.0",
25 changes: 25 additions & 0 deletions packages/apollo-angular/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Change log

## 9.0.0

### Major Changes

- [#2340](https://github.com/kamilkisiela/apollo-angular/pull/2340)
[`6d3d5ba`](https://github.com/kamilkisiela/apollo-angular/commit/6d3d5ba67a5a8d2778a021f1059559379ff99e8f)
Thanks [@PowerKiKi](https://github.com/PowerKiKi)! - - Requires `@apollo/client` 3.13.1
- Dropped `SubscriptionResult`, because it added extra maintenance work to keep native types in
sync, and it brought no value over using native type.
`diff - import type { SubscriptionResult } from 'apollo-angular'; + import type { FetchResult } from '@apollo/client/core'; `
- Most methods of `QueryRef` forward types from `@apollo/client`. That should allow always using
correct types from whichever `@apollo/client` version is installed without needing to touch
`apollo-angular`.
- `QueryRef.valueChanges` and `QueryRef.queryId` are readonly, because there is no reason for
those to be re-affected.

### Patch Changes

- [#2340](https://github.com/kamilkisiela/apollo-angular/pull/2340)
[`88656f0`](https://github.com/kamilkisiela/apollo-angular/commit/88656f00f4f4f8c757ef19e35b172a647e6e2300)
Thanks [@PowerKiKi](https://github.com/PowerKiKi)! - dependencies updates:
- Updated dependency
[`@apollo/client@^3.13.1` ↗︎](https://www.npmjs.com/package/@apollo/client/v/3.13.1) (from
`^3.10.0`, in `peerDependencies`)

## 8.0.2

### Patch Changes
4 changes: 2 additions & 2 deletions packages/apollo-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-angular",
"version": "8.0.2",
"version": "9.0.0",
"description": "Use your GraphQL data in your Angular app, with the Apollo Client",
"repository": {
"type": "git",
@@ -35,7 +35,7 @@
},
"peerDependencies": {
"@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0",
"@apollo/client": "^3.10.0",
"@apollo/client": "^3.13.1",
"graphql": "^15.0.0 || ^16.0.0",
"rxjs": "^6.0.0 || ^7.0.0"
},
1 change: 0 additions & 1 deletion packages/apollo-angular/src/index.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ export type {
QueryOptionsAlone,
ResultOf,
SubscriptionOptionsAlone,
SubscriptionResult,
VariablesOf,
WatchQueryOptions,
WatchQueryOptionsAlone,
68 changes: 38 additions & 30 deletions packages/apollo-angular/src/query-ref.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { from, Observable } from 'rxjs';
import { NgZone } from '@angular/core';
import type {
ApolloError,
ApolloQueryResult,
FetchMoreQueryOptions,
ObservableQuery,
OperationVariables,
SubscribeToMoreOptions,
TypedDocumentNode,
UpdateQueryOptions,
} from '@apollo/client/core';
import { NetworkStatus } from '@apollo/client/core';
import { EmptyObject, WatchQueryOptions } from './types';
@@ -46,14 +43,14 @@ function useInitialLoading<T, V extends OperationVariables>(obsQuery: Observable
export type QueryRefFromDocument<T extends TypedDocumentNode> =
T extends TypedDocumentNode<infer R, infer V> ? QueryRef<R, V & OperationVariables> : never;

export class QueryRef<T, V extends OperationVariables = EmptyObject> {
public valueChanges: Observable<ApolloQueryResult<T>>;
public queryId: ObservableQuery<T, V>['queryId'];
export class QueryRef<TData, TVariables extends OperationVariables = EmptyObject> {
public readonly valueChanges: Observable<ApolloQueryResult<TData>>;
public readonly queryId: ObservableQuery<TData, TVariables>['queryId'];

constructor(
private readonly obsQuery: ObservableQuery<T, V>,
private readonly obsQuery: ObservableQuery<TData, TVariables>,
ngZone: NgZone,
options: WatchQueryOptions<V, T>,
options: WatchQueryOptions<TVariables, TData>,
) {
const wrapped = wrapWithZone(from(fixObservable(this.obsQuery)), ngZone);

@@ -65,69 +62,80 @@ export class QueryRef<T, V extends OperationVariables = EmptyObject> {

// ObservableQuery's methods

public get options() {
public get options(): ObservableQuery<TData, TVariables>['options'] {
return this.obsQuery.options;
}

public get variables() {
public get variables(): ObservableQuery<TData, TVariables>['variables'] {
return this.obsQuery.variables;
}

public result(): Promise<ApolloQueryResult<T>> {
public result(): ReturnType<ObservableQuery<TData, TVariables>['result']> {
return this.obsQuery.result();
}

public getCurrentResult(): ApolloQueryResult<T> {
public getCurrentResult(): ReturnType<ObservableQuery<TData, TVariables>['getCurrentResult']> {
return this.obsQuery.getCurrentResult();
}

public getLastResult(): ApolloQueryResult<T> | undefined {
public getLastResult(): ReturnType<ObservableQuery<TData, TVariables>['getLastResult']> {
return this.obsQuery.getLastResult();
}

public getLastError(): ApolloError | undefined {
public getLastError(): ReturnType<ObservableQuery<TData, TVariables>['getLastError']> {
return this.obsQuery.getLastError();
}

public resetLastResults(): void {
public resetLastResults(): ReturnType<ObservableQuery<TData, TVariables>['resetLastResults']> {
return this.obsQuery.resetLastResults();
}

public refetch(variables?: V): Promise<ApolloQueryResult<T>> {
public refetch(
variables?: Parameters<ObservableQuery<TData, TVariables>['refetch']>[0],
): ReturnType<ObservableQuery<TData, TVariables>['refetch']> {
return this.obsQuery.refetch(variables);
}

public fetchMore<K = V>(
fetchMoreOptions: FetchMoreQueryOptions<K, T>,
): Promise<ApolloQueryResult<T>> {
public fetchMore<TFetchVars extends OperationVariables = TVariables>(
fetchMoreOptions: Parameters<QueryRef<TData, TFetchVars>['obsQuery']['fetchMore']>[0],
): ReturnType<QueryRef<TData, TFetchVars>['obsQuery']['fetchMore']> {
return this.obsQuery.fetchMore(fetchMoreOptions);
}

public subscribeToMore<MT = any, MV = EmptyObject>(
options: SubscribeToMoreOptions<T, MV, MT>,
): () => void {
// XXX: there's a bug in apollo-client typings
// it should not inherit types from ObservableQuery
return this.obsQuery.subscribeToMore(options as any);
public subscribeToMore<
TSubscriptionData = TData,
TSubscriptionVariables extends OperationVariables = TVariables,
>(
options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>,
): ReturnType<ObservableQuery<TData, TVariables>['subscribeToMore']> {
return this.obsQuery.subscribeToMore(options);
}

public updateQuery(mapFn: (previousQueryResult: T, options: UpdateQueryOptions<V>) => T): void {
public updateQuery(
mapFn: Parameters<ObservableQuery<TData, TVariables>['updateQuery']>[0],
): ReturnType<ObservableQuery<TData, TVariables>['updateQuery']> {
return this.obsQuery.updateQuery(mapFn);
}

public stopPolling(): void {
public stopPolling(): ReturnType<ObservableQuery<TData, TVariables>['stopPolling']> {
return this.obsQuery.stopPolling();
}

public startPolling(pollInterval: number): void {
public startPolling(
pollInterval: Parameters<ObservableQuery<TData, TVariables>['startPolling']>[0],
): ReturnType<ObservableQuery<TData, TVariables>['startPolling']> {
return this.obsQuery.startPolling(pollInterval);
}

public setOptions(opts: Partial<WatchQueryOptions<V, T>>) {
public setOptions(
opts: Parameters<ObservableQuery<TData, TVariables>['setOptions']>[0],
): ReturnType<ObservableQuery<TData, TVariables>['setOptions']> {
return this.obsQuery.setOptions(opts);
}

public setVariables(variables: V) {
public setVariables(
variables: Parameters<ObservableQuery<TData, TVariables>['setVariables']>[0],
): ReturnType<ObservableQuery<TData, TVariables>['setVariables']> {
return this.obsQuery.setVariables(variables);
}
}
11 changes: 3 additions & 8 deletions packages/apollo-angular/src/subscription.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import type { DocumentNode } from 'graphql';
import type { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import type { OperationVariables, TypedDocumentNode } from '@apollo/client/core';
import type { FetchResult, OperationVariables, TypedDocumentNode } from '@apollo/client/core';
import { Apollo } from './apollo';
import {
EmptyObject,
ExtraSubscriptionOptions,
SubscriptionOptionsAlone,
SubscriptionResult,
} from './types';
import { EmptyObject, ExtraSubscriptionOptions, SubscriptionOptionsAlone } from './types';

@Injectable()
export abstract class Subscription<T = any, V extends OperationVariables = EmptyObject> {
@@ -21,7 +16,7 @@ export abstract class Subscription<T = any, V extends OperationVariables = Empty
variables?: V,
options?: SubscriptionOptionsAlone<V, T>,
extra?: ExtraSubscriptionOptions,
): Observable<SubscriptionResult<T>> {
): Observable<FetchResult<T>> {
return this.apollo.use(this.client).subscribe<T, V>(
{
...options,
3 changes: 0 additions & 3 deletions packages/apollo-angular/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ExecutionResult } from 'graphql';
import type {
ApolloClientOptions,
MutationOptions as CoreMutationOptions,
@@ -69,8 +68,6 @@ export interface MutationOptions<TData = any, TVariables = EmptyObject>
export interface WatchFragmentOptions<TData = any, TVariables = EmptyObject>
extends CoreWatchFragmentOptions<TData, TVariables> {}

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

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

export type Flags = {
2 changes: 1 addition & 1 deletion packages/demo/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ export const appConfig: ApplicationConfig = {

return {
link: httpLink.create({
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
uri: 'https://swapi-graphql.netlify.app/graphql',
}),
cache: new InMemoryCache(),
};
Loading