Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field type permissions #54

Closed
flyhigh-hifi opened this issue Jun 4, 2018 · 5 comments
Closed

Field type permissions #54

flyhigh-hifi opened this issue Jun 4, 2018 · 5 comments

Comments

@flyhigh-hifi
Copy link

flyhigh-hifi commented Jun 4, 2018

Hi! I have tested permissions applied to type which is returned from query and it seems not to work when resolvers for type were not explicitly defined:
for e.g. this works when I do query me:

const resolvers = {
  Query: {
    me: (_, args, ctx) => ctx.user;
  },
  User: {
    name(parent, args, ctx) { return parent.name; }
  }
}

const permissions = shield({
  User: {
    name: allow
  }
})

and this doesn't, although it has allow rule:

const resolvers = {
  Query: {
    me: (_, args, ctx) => ctx.user;
  }
}

const permissions = shield({
  User: {
    name: allow
  }
})

Always getting Not Authorised! error.

@maticzav
Copy link
Owner

maticzav commented Jun 4, 2018

@flyhigh-hifi thanks for reporting this. Could you check out error logs using { debug: true } option?

Besides that, what's your version of graphql-shield and graphql-middleware/graphql-yoga?

@flyhigh-hifi
Copy link
Author

Versions:
shield: 2.1.0
yoga: 1.9.2

With debug as true:

TypeError: resolver is not a function
    at /Users/mark/Desktop/test/node_modules/graphql-yoga/node_modules/graphql-middleware/src/index.ts:46:9
    at /Users/mark/Desktop/test/node_modules/graphql-shield/src/index.ts:232:16
    at Generator.next (<anonymous>)
    at fulfilled (/Users/mark/Desktop/test/node_modules/graphql-shield/dist/index.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

@maticzav
Copy link
Owner

maticzav commented Jun 4, 2018

Try upgrading graphql-yoga to the latest version.

The issue about type resolvers has been resolved in one of the latest versions of graphql-middleware which should have, as well, been updated in Yoga.

Tell me if that worked out for you! 🙂

@flyhigh-hifi
Copy link
Author

Bunch of thanks to you, it did!

@maticzav
Copy link
Owner

maticzav commented Jun 4, 2018

No problem, I am glad it worked 😄

@maticzav maticzav closed this as completed Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants