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

Move away from deprecated things #2319

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/long-apes-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'apollo-angular': patch
---

Move away from deprecated things
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 @@ -160,7 +160,7 @@ export class HttpBatchLinkHandler extends ApolloLink {
const context: Context & { skipBatching?: boolean } = operation.getContext();

if (context.skipBatching) {
return Math.random().toString(36).substr(2, 9);
return Math.random().toString(36).substring(2, 11);
}

const headers =
Expand Down
7 changes: 3 additions & 4 deletions packages/apollo-angular/http/tests/http-batch-link.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClientModule, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpHeaders, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { ApolloLink, execute, gql, Operation } from '@apollo/client/core';
import { HttpBatchLink } from '../src/http-batch-link';
Expand All @@ -14,8 +14,7 @@ describe('HttpBatchLink', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, HttpClientTestingModule],
providers: [HttpBatchLink],
providers: [provideHttpClient(), provideHttpClientTesting(), HttpBatchLink],
});
httpLink = TestBed.inject(HttpBatchLink);
httpBackend = TestBed.inject(HttpTestingController);
Expand Down
9 changes: 4 additions & 5 deletions packages/apollo-angular/http/tests/http-link.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { print, stripIgnoredCharacters } from 'graphql';
import { mergeMap } from 'rxjs/operators';
import { HttpClientModule, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpHeaders, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { ApolloLink, execute, gql, InMemoryCache } from '@apollo/client/core';
import { Apollo } from '../../src';
Expand All @@ -17,8 +17,7 @@ describe('HttpLink', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule, HttpClientTestingModule],
providers: [HttpLink, Apollo],
providers: [provideHttpClient(), provideHttpClientTesting(), HttpLink, Apollo],
});
httpLink = TestBed.inject(HttpLink);
httpBackend = TestBed.inject(HttpTestingController);
Expand Down Expand Up @@ -544,7 +543,7 @@ describe('HttpLink', () => {
});

test('should work with mergeMap', done => {
const apollo: Apollo = TestBed.get(Apollo);
const apollo = TestBed.inject(Apollo);

const op1 = {
query: gql`
Expand Down
21 changes: 6 additions & 15 deletions packages/apollo-angular/http/tests/ssr.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { filter, first } from 'rxjs/operators';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { firstValueFrom } from 'rxjs';
import { filter } from 'rxjs/operators';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { ApplicationRef, Component, destroyPlatform, getPlatform, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
INITIAL_CONFIG,
platformServer,
Expand Down Expand Up @@ -66,12 +66,8 @@ describe.skip('integration', () => {

@NgModule({
declarations: [AsyncServerApp],
imports: [
BrowserModule.withServerTransition({ appId: 'async-server' }),
ServerModule,
HttpClientTestingModule,
],
providers: [HttpLink],
imports: [ServerModule],
providers: [provideHttpClientTesting(), HttpLink],
bootstrap: [AsyncServerApp],
})
class AsyncServerModule {}
Expand All @@ -87,12 +83,7 @@ describe.skip('integration', () => {
]);
const moduleRef = await platform.bootstrapModule(AsyncServerModule);
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
await applicationRef.isStable
.pipe(
filter((isStable: boolean) => isStable),
first(),
)
.toPromise();
await firstValueFrom(applicationRef.isStable.pipe(filter(isStable => isStable)));
const str = platform.injector.get(PlatformState).renderToString();

expect(clearNgVersion(str)).toMatchSnapshot();
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-angular/testing/tests/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ describe('Integration', () => {
],
});

const apollo: Apollo = TestBed.get(Apollo);
const backend: ApolloTestingController = TestBed.get(ApolloTestingController);
const apollo = TestBed.inject(Apollo);
const backend = TestBed.inject(ApolloTestingController);

const query = gql`
{
Expand Down
12 changes: 6 additions & 6 deletions packages/apollo-angular/tests/Apollo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('Apollo', () => {
obs.subscribe({
error,
complete: () => {
expect(error).not.toBeCalled();
expect(error).not.toHaveBeenCalled();
done();
},
});
Expand All @@ -240,11 +240,11 @@ describe('Apollo', () => {

const obs = apollo.query({} as any);

expect(client.query).not.toBeCalled();
expect(client.query).not.toHaveBeenCalled();

obs.subscribe({
complete: () => {
expect(client.query).toBeCalled();
expect(client.query).toHaveBeenCalled();
done();
},
});
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('Apollo', () => {
obs.subscribe({
error,
complete: () => {
expect(error).not.toBeCalled();
expect(error).not.toHaveBeenCalled();
done();
},
});
Expand All @@ -394,11 +394,11 @@ describe('Apollo', () => {

const obs = apollo.mutate({} as any);

expect(client.mutate).not.toBeCalled();
expect(client.mutate).not.toHaveBeenCalled();

obs.subscribe({
complete: () => {
expect(client.mutate).toBeCalled();
expect(client.mutate).toHaveBeenCalled();
done();
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-angular/tests/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientModule } from '@angular/common/http';
import { provideHttpClient } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import { InMemoryCache } from '@apollo/client/core';
import { mockSingleLink } from '@apollo/client/testing';
Expand All @@ -8,8 +8,8 @@ describe('Integration', () => {
describe('default', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientModule],
providers: [
provideHttpClient(),
provideApollo(() => {
return {
link: mockSingleLink(),
Expand Down
Loading