Skip to content

Commit

Permalink
Drop most mention of module in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Sep 18, 2024
1 parent 27a7496 commit d56c5cb
Show file tree
Hide file tree
Showing 15 changed files with 413 additions and 682 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-carrots-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'apollo-angular': patch
---

Update documentation to standalone usage
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Apollo, APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { ApplicationConfig, inject } from '@angular/core';
import { inject, Provider } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';

const uri = '<%= endpoint %>'; // <-- add the URL of the GraphQL server here
Expand All @@ -12,7 +12,7 @@ export function apolloOptionsFactory(): ApolloClientOptions<any> {
};
}

export const graphqlProvider: ApplicationConfig['providers'] = [
export const graphqlProvider: Provider = [
Apollo,
{
provide: APOLLO_OPTIONS,
Expand Down
34 changes: 15 additions & 19 deletions website/src/pages/docs/caching/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,21 @@ additional libraries are required.

Create an `InMemoryCache` object and provide it to the `APOLLO_OPTIONS` token, like so:

```ts
import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
import { InMemoryCache } from '@apollo/client/core';

@NgModule({
imports: [ApolloModule],
providers: [
{
provide: APOLLO_OPTIONS,
useFactory() {
return {
// ...other arguments...
cache: new InMemoryCache(options),
};
},
},
],
})
class AppModule {}
```ts filename="graphql.provider.ts"
import { HttpBatchLink } from 'apollo-angular/http';
import { inject } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
function apolloOptionsFactory(): ApolloClientOptions<any> {
const httpBatchLink = inject(HttpBatchLink);
return {
link: httpBatchLink.create({ uri: '/graphql' }),
cache: new InMemoryCache({
/* your options here */
}), r options ...
};
}
};
}
```

The `InMemoryCache` constructor accepts a variety of
Expand Down
49 changes: 22 additions & 27 deletions website/src/pages/docs/data/mutations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -254,36 +254,31 @@ The result of `Apollo.mutate()` contains `loading` property. By default, it's al
result is emitted with the response from the ApolloLink execution chain. In order to correct it you
can enable `useMutationLoading` flag in configuration.

```ts
import { APOLLO_FLAGS, APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
```ts filename="graphql.provider.ts"
import { Apollo, APOLLO_FLAGS, APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { HttpClientModule } from '@angular/common/http';
import { InMemoryCache } from '@apollo/client/core';

@NgModule({
imports: [BrowserModule, ApolloModule, HttpClientModule],
providers: [
{
provide: APOLLO_FLAGS,
useValue: {
useMutationLoading: true, // enable it here
},
import { inject, Provider } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
function apolloOptionsFactory(): ApolloClientOptions<any> {
const httpLink = inject(HttpLink);
return {
link: httpLink.create({ uri: '/graphql' }),
cache: new InMemoryCache(), options ...
};
}
};
}
export const graphqlProvider: Provider = [
Apollo,
{ provide: APOLLO_OPTIONS, useFactory: apolloOptionsFactory },
{
provide: APOLLO_FLAGS,
useValue: {
useMutationLoading: true, it here
},
{
provide: APOLLO_OPTIONS,
useFactory: (httpLink: HttpLink) => {
return {
cache: new InMemoryCache(),
link: httpLink.create({
uri: 'https://48p1r2roz4.sse.codesandbox.io',
}),
};
},
deps: [HttpLink],
},
],
})
export class AppModule {}
},
];
```

<Callout type="warning">
Expand Down
Loading

0 comments on commit d56c5cb

Please sign in to comment.