GraphQL
Casbin follows the recommended GraphQL authorization pattern by implementing authorization as a single source of truth: https://graphql.org/learn/authorization/. This means Casbin logic should sit between the GraphQL layer and your business logic.
// Casbin authorization logic lives inside postRepository
var postRepository = require('postRepository');
var postType = new GraphQLObjectType({
name: 'Post',
fields: {
body: {
type: GraphQLString,
resolve: (post, args, context, { rootValue }) => {
return postRepository.getBody(context.user, post);
}
}
}
});
Available GraphQL Middlewares
Below is a complete list of Casbin GraphQL middlewares. Third-party middleware contributions are welcome—please let us know and we'll include them here.
| Middleware | Implementazione GraphQL | Autore | Descrizione |
|---|---|---|---|
| graphql-authz | graphql | Casbin | Authorization middleware for graphql-go |
| graphql-casbin | graphql | @esmaeilpour | GraphQL and Casbin integration example |
| gqlgen_casbin_RBAC_example | gqlgen | @WenyXu | (vuoto) |
| Middleware | Implementazione GraphQL | Autore | Descrizione |
|---|---|---|---|
| graphql-authz | GraphQL.js | Casbin | Casbin authorization middleware for GraphQL.js |
| Middleware | Implementazione di GraphQL | Autore | Descrizione |
|---|---|---|---|
| graphql-authz | GraphQL-core 3 | @Checho3388 | Casbin authorization middleware for GraphQL-core 3 |