1.0.6 • Published 4 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
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0-beta.2
5 years ago
1.0.0-beta.1
5 years ago