-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New
provideApollo()
and provideNamedApollo()
Those two providers make it simpler to provide Apollo with options and flags to the application. Token injections, `APOLLO_OPTIONS`, `APOLLO_NAMED_OPTIONS` and `APOLLO_FLAGS` are not needed anymore in application code. Though they might still be used for custom providing techniques. `ApolloModule` is deprecated because it brings no value. Especially with the introduction of the two providing functions.
- Loading branch information
Showing
23 changed files
with
367 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'apollo-angular': minor | ||
--- | ||
|
||
New `provideApollo()` and `provideNamedApollo()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
packages/apollo-angular/schematics/install/files/standalone/graphql.provider.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,52 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { NgModule, Provider } from '@angular/core'; | ||
import { ApolloClientOptions } from '@apollo/client/core'; | ||
import { Apollo } from './apollo'; | ||
import { APOLLO_FLAGS, APOLLO_NAMED_OPTIONS, APOLLO_OPTIONS } from './tokens'; | ||
import { Flags, NamedOptions } from './types'; | ||
|
||
export const PROVIDERS = [Apollo]; | ||
|
||
/** | ||
* This is deprecated and will be removed in the next major version, because | ||
* Angular is moving toward a moduleless ecosystem. | ||
* | ||
* Instead, use either `provideApollo()` or `provideNamedApollo()`. | ||
* | ||
* @deprecated | ||
*/ | ||
@NgModule({ | ||
providers: PROVIDERS, | ||
providers: [Apollo], | ||
}) | ||
export class ApolloModule {} | ||
|
||
export function provideApollo<TCacheShape = any>( | ||
optionsFactory: () => ApolloClientOptions<TCacheShape>, | ||
flags: Flags = {}, | ||
): Provider { | ||
return [ | ||
Apollo, | ||
{ | ||
provide: APOLLO_OPTIONS, | ||
useFactory: optionsFactory, | ||
}, | ||
{ | ||
provide: APOLLO_FLAGS, | ||
useValue: flags, | ||
}, | ||
]; | ||
} | ||
|
||
export function provideNamedApollo( | ||
optionsFactory: () => NamedOptions, | ||
flags: Flags = {}, | ||
): Provider { | ||
return [ | ||
Apollo, | ||
{ | ||
provide: APOLLO_NAMED_OPTIONS, | ||
useFactory: optionsFactory, | ||
}, | ||
{ | ||
provide: APOLLO_FLAGS, | ||
useValue: flags, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import { provideApollo } from 'apollo-angular'; | ||
import { HttpLink } from 'apollo-angular/http'; | ||
import { provideHttpClient } from '@angular/common/http'; | ||
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; | ||
import { ApplicationConfig, inject, provideZoneChangeDetection } from '@angular/core'; | ||
import { provideRouter } from '@angular/router'; | ||
import { InMemoryCache } from '@apollo/client/core'; | ||
import { routes } from './app.routes'; | ||
import { graphqlProvider } from './graphql.provider'; | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideZoneChangeDetection({ eventCoalescing: true }), | ||
provideRouter(routes), | ||
provideHttpClient(), | ||
graphqlProvider, | ||
provideApollo(() => { | ||
const httpLink = inject(HttpLink); | ||
|
||
return { | ||
link: httpLink.create({ | ||
uri: 'https://swapi-graphql.netlify.app/.netlify/functions/index', | ||
}), | ||
cache: new InMemoryCache(), | ||
}; | ||
}), | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.