graphql-auth
graphql-auth copied to clipboard
no resolver when adding directive to scalar field
Tried adding a directive to a field
type Article {
id: ID!
authorId: ID!
authorName: String!
articleName: String!
link: String! @hasScope(scope: ["write:articles"])
review: Review
}
...but it throws on oldResolve.call
as it does not have a field.resolve
.
https://github.com/chenkie/graphql-auth/blob/8d474576a13247b03d2862e9307ed4a8b4ea958d/directives/index.js#L68-L72
I'm not sure what would be appropriate here (have never built a graphql server before).
Made it work by making the following additions:
const {defaultFieldResolver} = require('graphql');
// ...
let promise = oldResolve ? oldResolve.call(field, ...arguments) : defaultFieldResolver.call(field, ...arguments)
const oldResolve = field.resolve || defaultFieldResolver;
@fc-io : shorten. :D