We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 16f8097 commit b285e8fCopy full SHA for b285e8f
packages/graphql-authentication/src/utils.ts
@@ -4,11 +4,13 @@ import { ID } from './Adapter';
4
5
export interface Context {
6
graphqlAuthentication: IGraphqlAuthenticationConfig;
7
- request: any;
+ request?: any;
8
+ req?: any;
9
}
10
11
function _getUserId(ctx: Context): string {
- const Authorization = ctx.request.get('Authorization');
12
+ // For Apollo Server 2.0+ it is ctx.req and for GraphQL Yoga ctx.request. Maybe there is a better way...
13
+ const Authorization = (ctx.req || ctx.request).get('Authorization');
14
if (Authorization) {
15
const token = Authorization.replace('Bearer ', '');
16
const { userId } = jwt.verify(token, ctx.graphqlAuthentication.secret) as {
0 commit comments