Package Exports
- @graphql-authz/apollo-server-plugin
- @graphql-authz/apollo-server-plugin/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@graphql-authz/apollo-server-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@graphql-authz/apollo-server-plugin
Configuring Apollo Server
Ensure context parser is configured to perform authentication and add user info to context
const server = new ApolloServer({
...
context: ({ req }) => {
return {
user: someHowAuthenticateUser(req.get("authorization"))),
};
},
...
});For Directives usage
Apply authZDirectiveTransformer to schema and add plugin to apollo-server
import { makeExecutableSchema } from '@graphql-tools/schema';
import { authZDirective } from '@graphql-authz/directive';
import { authZApolloPlugin } from "@graphql-authz/apollo-server-plugin";
const { authZDirectiveTransformer } = authZDirective();
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
const transformedSchema = authZDirectiveTransformer(schema);
const server = new ApolloServer({
...
schema: transformedSchema,
plugins: [authZApolloPlugin({ rules })],
...
});For Extensions usage
Add plugin to apollo-server
import { authZApolloPlugin } from "@graphql-authz/apollo-server-plugin";;
const server = new ApolloServer({
...
plugins: [authZApolloPlugin({ rules })],
...
});For AuthSchema usage
Add plugin to apollo-server with an additional parameter authSchema
import { authZApolloPlugin } from "@graphql-authz/apollo-server-plugin";;
const server = new ApolloServer({
...
plugins: [authZApolloPlugin({ rules, authSchema })],
...
});