BlueLibs APOLLO SECURITY BUNDLE
This bundle is to inject into the context the token read from the request and decoded to an userId via the SecurityBundle.
Installation
npm i -S @bluelibs/apollo-bundle @bluelibs/apollo-security-bundle
import { ApolloSecurityBundle } from "@bluelibs/apollo-security-bundle";
kernel.addBundle(
new ApolloSecurityBundle({
// options go here
})
);
Options:
export interface IApolloSecurityBundleConfig {
// All true by default
support: {
headers?: boolean,
cookies?: boolean,
websocket?: boolean,
};
// bluelibs-token is the default for all
identifiers: {
headers?: string,
cookies?: string,
// For websocket you have to send the connection params in order to work
websocket?: string,
};
}
Usage:
import { ISecurityContext } from "@bluelibs/apollo-security-bundle";
load({
resolvers: {
Query: {
findMyPosts(_, args, context: ISecurityContext) {
if (!context.userId) {
// You can throw an error.
}
},
},
},
});
Support
This package is part of BlueLibs family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here