1.0.6 • Published 5 years ago
aws-cognito-graphql-directive v1.0.6
aws-cognito-graphql-directive
Directive to check authentication against AWS cognito
Installation
> npm install
Setup
import { AuthDirective, authTypeDefs, getAuthContext } from 'aws-cognito-graphql-drective';
const generateContext: ContextFunction<{event: APIGatewayEvent}, MyGraphQLContext> =
async ({event: {headers}}) => ({
auth: await getAuthContext(headers, {
awsRegion: '',
userPoolId: ''
})
});
export const handler = new ApolloServer({
context: generateContext,
typeDefs: merge(authTypeDefs, myTypeDefs),
// ..
schemaDirectives: {
auth: AuthDirective
}
}).createHandler();
Requiring authentication
type Query {
authRequiredQuery: MyResult @auth
adminGroupOnlyQuery: MyResult @auth(groups: ["admin"])
}
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0-beta.2
6 years ago
1.0.0-beta.1
6 years ago