Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep import to leverage ESM #2307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/apollo-angular/headers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpHeaders } from '@angular/common/http';
import { ApolloLink, NextLink, Operation } from '@apollo/client/core';
import { ApolloLink, NextLink, Operation } from '@apollo/client/core/index.js';

export const httpHeaders = () => {
return new ApolloLink((operation: Operation, forward: NextLink) => {
Expand Down
7 changes: 6 additions & 1 deletion packages/apollo-angular/headers/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { HttpHeaders } from '@angular/common/http';
import { ApolloLink, execute, gql, Observable as LinkObservable } from '@apollo/client/core';
import {
ApolloLink,
execute,
gql,
Observable as LinkObservable,
} from '@apollo/client/core/index.js';
import { httpHeaders } from '../src';

const query = gql`
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/src/http-batch-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FetchResult,
Observable as LinkObservable,
Operation,
} from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { BatchHandler, BatchLink } from '@apollo/client/link/batch';
import { BatchOptions, Body, Context, OperationPrinter, Options, Request } from './types';
import { createHeadersWithClientAwareness, fetch, mergeHeaders, prioritize } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/src/http-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FetchResult,
Observable as LinkObservable,
Operation,
} from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { pick } from './http-batch-link';
import { Body, Context, OperationPrinter, Options, Request } from './types';
import { createHeadersWithClientAwareness, fetch, mergeHeaders } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DocumentNode } from 'graphql';
import { HttpHeaders } from '@angular/common/http';
import { Operation } from '@apollo/client/core';
import { Operation } from '@apollo/client/core/index.js';

export type HttpRequestOptions = {
headers?: HttpHeaders;
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/tests/http-batch-link.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClientModule, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { ApolloLink, execute, gql, Operation } from '@apollo/client/core';
import { ApolloLink, execute, gql, Operation } from '@apollo/client/core/index.js';
import { HttpBatchLink } from '../src/http-batch-link';

const noop = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/tests/http-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mergeMap } from 'rxjs/operators';
import { HttpClientModule, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { ApolloLink, execute, gql, InMemoryCache } from '@apollo/client/core';
import { ApolloLink, execute, gql, InMemoryCache } from '@apollo/client/core/index.js';
import { Apollo } from '../../src';
import { HttpLink } from '../src/http-link';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/http/tests/ssr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
renderModule,
ServerModule,
} from '@angular/platform-server';
import { execute, gql } from '@apollo/client/core';
import { execute, gql } from '@apollo/client/core/index.js';
import { HttpLink } from '../src/http-link';

describe.skip('integration', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ApolloLink, execute, FetchResult, gql, Observable, Operation } from '@apollo/client/core';
import {
ApolloLink,
execute,
FetchResult,
gql,
Observable,
Operation,
} from '@apollo/client/core/index.js';
import { createPersistedQueryLink } from '../src';

const query = gql`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { NgModule } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core/index.js';

const uri = '<%= endpoint %>'; // <-- add the URL of the GraphQL server here
export function createApollo(httpLink: HttpLink): ApolloClientOptions<any> {
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo-angular/schematics/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function includeAsyncIterableLib(): Rule {
'\n' +
tags.stripIndent`
We couldn't find '${requiredLib}' in the list of library files to be included in the compilation.
It's required by '@apollo/client/core' package so please add it to your tsconfig.
It's required by '@apollo/client/core/index.js' package so please add it to your tsconfig.
` +
'\n',
);
Expand Down Expand Up @@ -151,7 +151,7 @@ function allowSyntheticDefaultImports(): Rule {
'\n' +
tags.stripIndent`
We couldn't enable 'allowSyntheticDefaultImports' flag.
It's required by '@apollo/client/core' package so please add it to your tsconfig.
It's required by '@apollo/client/core/index.js' package so please add it to your tsconfig.
` +
'\n',
);
Expand Down Expand Up @@ -201,7 +201,7 @@ function importSetup(options: Schema): Rule {
link: httpLink.create({
uri: '<%= endpoint %>',
}),
cache: new ${external('InMemoryCache', '@apollo/client/core')}(),
cache: new ${external('InMemoryCache', '@apollo/client/core/index.js')}(),
};
})`;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/apollo-module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule, Provider } from '@angular/core';
import { ApolloClientOptions } from '@apollo/client/core';
import { ApolloClientOptions } from '@apollo/client/core/index.js';
import { Apollo } from './apollo';
import { APOLLO_FLAGS, APOLLO_NAMED_OPTIONS, APOLLO_OPTIONS } from './tokens';
import { Flags, NamedOptions } from './types';
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-angular/src/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type {
QueryOptions,
SubscriptionOptions,
WatchFragmentResult,
} from '@apollo/client/core';
import { ApolloClient } from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { ApolloClient } from '@apollo/client/core/index.js';
import { QueryRef } from './query-ref';
import { APOLLO_FLAGS, APOLLO_NAMED_OPTIONS, APOLLO_OPTIONS } from './tokens';
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/gql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql as gqlTag, TypedDocumentNode } from '@apollo/client/core';
import { gql as gqlTag, TypedDocumentNode } from '@apollo/client/core/index.js';

function typedGQLTag<Result, Variables>(
literals: ReadonlyArray<string> | Readonly<string>,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { TypedDocumentNode } from '@apollo/client/core';
export type { TypedDocumentNode } from '@apollo/client/core/index.js';
export { ApolloModule, provideApollo, provideNamedApollo } from './apollo-module';
export { Apollo, ApolloBase } from './apollo';
export { QueryRef, QueryRefFromDocument } from './query-ref';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/mutation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { OperationVariables, TypedDocumentNode } from '@apollo/client/core/index.js';
import { Apollo } from './apollo';
import type { EmptyObject, MutationOptionsAlone, MutationResult } from './types';

Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-angular/src/query-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type {
SubscribeToMoreOptions,
TypedDocumentNode,
UpdateQueryOptions,
} from '@apollo/client/core';
import { NetworkStatus } from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { NetworkStatus } from '@apollo/client/core/index.js';
import { EmptyObject, WatchQueryOptions } from './types';
import { fixObservable, wrapWithZone } from './utils';

Expand Down
6 changes: 5 additions & 1 deletion packages/apollo-angular/src/query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { DocumentNode } from 'graphql';
import type { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import type { ApolloQueryResult, OperationVariables, TypedDocumentNode } from '@apollo/client/core';
import type {
ApolloQueryResult,
OperationVariables,
TypedDocumentNode,
} from '@apollo/client/core/index.js';
import { Apollo } from './apollo';
import { QueryRef } from './query-ref';
import { EmptyObject, QueryOptionsAlone, WatchQueryOptionsAlone } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/subscription.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { OperationVariables, TypedDocumentNode } from '@apollo/client/core/index.js';
import { Apollo } from './apollo';
import {
EmptyObject,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InjectionToken } from '@angular/core';
import type { ApolloClientOptions } from '@apollo/client/core';
import type { ApolloClientOptions } from '@apollo/client/core/index.js';
import type { Flags, NamedOptions } from './types';

export const APOLLO_FLAGS = new InjectionToken<Flags>('APOLLO_FLAGS');
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
FetchResult,
OperationVariables,
TypedDocumentNode,
} from '@apollo/client/core';
} from '@apollo/client/core/index.js';

export type EmptyObject = {
[key: string]: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
ApolloQueryResult,
FetchResult,
ObservableQuery,
} from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { MutationResult } from './types';

export function fromPromise<T>(promiseFn: () => Promise<T>): Observable<T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DocumentNode, print } from 'graphql';
import { Observer } from 'rxjs';
import { Injectable } from '@angular/core';
import { FetchResult, Observable as LinkObservable } from '@apollo/client/core';
import { FetchResult, Observable as LinkObservable } from '@apollo/client/core/index.js';
import { ApolloTestingController, MatchOperation } from './controller';
import { Operation, TestOperation } from './operation';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ApolloLink,
InMemoryCache,
Operation as LinkOperation,
} from '@apollo/client/core';
} from '@apollo/client/core/index.js';
import { ApolloTestingBackend } from './backend';
import { ApolloTestingController } from './controller';
import { Operation } from './operation';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/src/operation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExecutionResult, GraphQLError } from 'graphql';
import { Observer } from 'rxjs';
import { ApolloError, FetchResult, Operation as LinkOperation } from '@apollo/client/core';
import { ApolloError, FetchResult, Operation as LinkOperation } from '@apollo/client/core/index.js';

const isApolloError = (err: any): err is ApolloError => err && err.hasOwnProperty('graphQLErrors');

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/tests/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Apollo } from 'apollo-angular';
import { print } from 'graphql';
import { TestBed } from '@angular/core/testing';
import { gql, InMemoryCache } from '@apollo/client/core';
import { gql, InMemoryCache } from '@apollo/client/core/index.js';
import { addTypenameToDocument } from '@apollo/client/utilities';
import { APOLLO_TESTING_CACHE, ApolloTestingController, ApolloTestingModule } from '../src';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/tests/module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Apollo } from 'apollo-angular';
import { TestBed } from '@angular/core/testing';
import { ApolloReducerConfig, gql, InMemoryCache } from '@apollo/client/core';
import { ApolloReducerConfig, gql, InMemoryCache } from '@apollo/client/core/index.js';
import { APOLLO_TESTING_CACHE, ApolloTestingController, ApolloTestingModule } from '../src';

describe('ApolloTestingModule', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/testing/tests/operation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloLink, execute, gql } from '@apollo/client/core';
import { ApolloLink, execute, gql } from '@apollo/client/core/index.js';
import { ApolloTestingBackend } from '../src/backend';
import { buildOperationForLink } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/tests/Apollo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable, of } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { NgZone } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { ApolloLink, InMemoryCache, NetworkStatus } from '@apollo/client/core';
import { ApolloLink, InMemoryCache, NetworkStatus } from '@apollo/client/core/index.js';
import { mockSingleLink } from '@apollo/client/testing';
import { Apollo, ApolloBase } from '../src/apollo';
import { gql } from '../src/gql';
Expand Down
7 changes: 6 additions & 1 deletion packages/apollo-angular/tests/QueryRef.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Subject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { NgZone } from '@angular/core';
import { ApolloClient, ApolloLink, InMemoryCache, ObservableQuery } from '@apollo/client/core';
import {
ApolloClient,
ApolloLink,
InMemoryCache,
ObservableQuery,
} from '@apollo/client/core/index.js';
import { mockSingleLink } from '@apollo/client/testing';
import { gql } from '../src/gql';
import { QueryRef } from '../src/query-ref';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-angular/tests/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClientModule } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';
import { mockSingleLink } from '@apollo/client/testing';
import { Apollo, provideApollo } from '../src';

Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpLink } from 'apollo-angular/http';
import { provideHttpClient } from '@angular/common/http';
import { ApplicationConfig, inject, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';
import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/caching/advanced-topics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ a different query, Apollo Client doesn't know that. To tell Apollo Client where
existing `book` data, we can define a field policy `read` function for the `book` field:

```ts
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';

const cache = new InMemoryCache({
typePolicies: {
Expand Down Expand Up @@ -383,7 +383,7 @@ write to the cache with a short configurable debounce interval.

```ts
import { LocalStorageWrapper, persistCacheSync } from 'apollo3-cache-persist';
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';

const cache = new InMemoryCache();

Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/docs/caching/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Create an `InMemoryCache` object and provide to Apollo options, like so:
import { provideApollo } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { inject } from '@angular/core';
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';

provideApollo(() => {
const httpLink = inject(HttpLink);
Expand Down Expand Up @@ -168,7 +168,7 @@ If you need to define a single fallback `keyFields` function that isn't specific
`__typename`, you can use the `dataIdFromObject` function that was introduced in Apollo Client 2.x:

```ts
import { defaultDataIdFromObject } from '@apollo/client/core';
import { defaultDataIdFromObject } from '@apollo/client/core/index.js';

const cache = new InMemoryCache({
dataIdFromObject(responseObject) {
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/data/mutations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ can enable `useMutationLoading` flag in configuration.
import { provideApollo } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { inject } from '@angular/core';
import { InMemoryCache } from '@apollo/client/core';
import { InMemoryCache } from '@apollo/client/core/index.js';

provideApollo(
() => {
Expand Down
Loading
Loading