the-guild-org / the-guild-org/apollo-angular
Feedback for “Subscriptions”
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 309
- Avg merge
- 1h 45m
- Merged PRs (30d)
- 3
Description
Authentication on the subscription topic in the documentation is unclear. I failed to authenticate using the following link over my named client.
const token = 'my_token';
const basic = setContext(() => ({
headers: {
Accept: 'charset=utf-8'
}
}));
const authLink = setContext((operation, context) => ({
headers: {
Authorization: `Bearer ${token}`,
},
}));
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === Kind.OPERATION_DEFINITION &&
definition.operation === OperationTypeNode.SUBSCRIPTION
);
},
new WebSocketLink({
uri: `ws://localhost:5079/graphql`,
options: {
reconnect: true,
connectionParams: () => ({
authToken: `Bearer ${token}`, // also tried using Authorization: `Bearer ${token}`,
}),
},
}),
authLink.concat(inject(HttpLink).create({
uri: `http://localhost:5079/graphql`,
})),
);
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(withFetch()),
provideNamedApollo(() => ({
myNamedClient: {
link: ApolloLink.from([
basic,
splitLink
]),
cache: new InMemoryCache(),
}
}))
]
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to the Subscriptions authentication documentation and provides an Angular/TypeScript Apollo setup using a named client, an HTTP auth link, and WebSocket connection parameters. Locate that documentation and its subscription authentication examples first; reproduce the named-client setup and verify that the documented authentication configuration works for subscriptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, graphql, typescript
- Domain
- api, authentication, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100