Skip to content

Commit

Permalink
fixed a bug with permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
alirizwan committed Sep 2, 2023
1 parent 291b15c commit b437e3c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphcraft",
"version": "1.1.3",
"version": "1.1.5",
"description": "Rapildy build and extend GraphQL API based on Sequelize models. This library helps you focus on business logic while taking care of GraphQL schema automatically.",
"main": "src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/mutations/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function createMutation (graphqlParams, mutationOptions) {
const bulkIdentifier = uuid();

const variablePath = { args, context };
const setValues = (permissions.set || []).reduce((all, condition) => {
const setValues = ((permissions || {}).set || []).reduce((all, condition) => {

if (typeof condition.value === 'string' && condition.value.startsWith(':')) {
all[condition.field] = _.get(variablePath, condition.value.replace(':', ''));
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/mutations/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function destroyMutation(graphqlParams, mutationOptions) {
throw Error('Invalid operation input.');
}

const clauses = (permissions.conditions || []).reduce((all, condition) => {
const clauses = ((permissions || {}).conditions || []).reduce((all, condition) => {

if (typeof condition.value === 'string' && condition.value.startsWith(':')) {
all[condition.field] = _.get(variablePath, condition.value.replace(':', ''));
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/mutations/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async function updateMutation (graphqlParams, mutationOptions) {
const variablePath = { args, context };
const scope = Array.isArray(model.graphql.scopes) ? { method: [model.graphql.scopes[0], _.get(variablePath, model.graphql.scopes[1], model.graphql.scopes[2] || null)] } : model.graphql.scopes;

const clauses = (permissions.conditions || []).reduce((all, condition) => {
const clauses = ((permissions || {}).conditions || []).reduce((all, condition) => {

if (typeof condition.value === 'string' && condition.value.startsWith(':')) {
all[condition.field] = _.get(variablePath, condition.value.replace(':', ''));
Expand Down

0 comments on commit b437e3c

Please sign in to comment.