This repository is just the result of a graphql-shield library study
git clone https://github.com/jdgabriel/basic-graphql-shield.git
yarn install
yarn dev
All authentication is done through functions that define the user and their access level, if used.
// Import shield
import { shield } from 'graphql-shield';
// Import any custon rules
import isAuthenticated from './isAuthenticated';
export default shield({
Query: {
hello: isAuthenticated
}
});
// Import rule
import { rule } from 'graphql-shield';
export default rule()(async (parent, args, ctx, info) => {
return ctx.user !== null;
});
Gabriel Duarte