the-guild-org / the-guild-org/apollo-angular

ClientAwareness headers in v12 applied only when setting them in defaultContext

Open
#2,385 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
309
Avg merge
1h 45m
Merged PRs (30d)
3

Description

Describe the bug

When configuring ClientAwareness headers in apollo-angular v12, they only will become applied to the request when configuring them in the query context or by configuring them globally in the defaultContext. But the regular way to configure them directly in the ApolloClient.Options like before v12, doesn't work anymore:

provideApollo(() => ({
  link: inject(HttpLink).create({
    uri: '/graphql',
    withCredentials: true
  }),
  cache: new InMemoryCache(),
  clientAwareness: { // <-- this is the regular place to configure clientAwareness which worked before v12
    name: 'my-client-name',
    version: 'dev.0.0.1'
  },
  defaultContext: {
    clientAwareness: {  // <-- only when adding the clientAwareness config here, the related headers will become applied 
      name: 'my-client-name',
      version: 'dev.0.0.1'
    }
  }
}));

Expected behavior

clientAwareness configuration should be applied when adding them to the default location in ApolloClient.Options as before v12

Environment:

- @angular/cli@20.3.9
- @angular/core@20.3.10
- @apollo/client@4.0.9
- apollo-angular@12.1.0
- graphql@16.10.0
- typescript@5.9.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the configuration shown in the issue and trace how clientAwareness is handled in ApolloClient.Options versus defaultContext. Verify the request headers produced by each configuration, then add or update coverage for the regular clientAwareness option so the expected headers are applied without defaultContext.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.