Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdgabriel/basic-graphql-shield
Basic Graphql Shield with Apollo Server
https://github.com/jdgabriel/basic-graphql-shield
apollo-server graphql graphql-middleware graphql-server graphql-shield
Last synced: 10 days ago
JSON representation
Basic Graphql Shield with Apollo Server
- Host: GitHub
- URL: https://github.com/jdgabriel/basic-graphql-shield
- Owner: jdgabriel
- Created: 2019-10-26T00:06:51.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:43:21.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T06:03:52.190Z (7 months ago)
- Topics: apollo-server, graphql, graphql-middleware, graphql-server, graphql-shield
- Language: JavaScript
- Homepage:
- Size: 532 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic GraphQL Shield
This repository is just the result of a [graphql-shield](https://github.com/jdgabriel/basic-graphql-shield) library study
### How to use and test yourself
```
git clone https://github.com/jdgabriel/basic-graphql-shield.git
yarn install
``````
yarn dev
```### Shield of grahpql-shield
All authentication is done through functions that define the user and their access level, if used.
##### FILE: ./src/permission
```javascript
// Import shield
import { shield } from 'graphql-shield';// Import any custon rules
import isAuthenticated from './isAuthenticated';export default shield({
Query: {
hello: isAuthenticated
}
});
```##### FILE: ./src/permission/isAuthenticated
```javascript
// Import rule
import { rule } from 'graphql-shield';export default rule()(async (parent, args, ctx, info) => {
return ctx.user !== null;
});
```## Licence MIT
Gabriel Duarte