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

no resolver when adding directive to scalar field #1

Open
fc-io opened this issue Nov 18, 2017 · 1 comment
Open

no resolver when adding directive to scalar field #1

fc-io opened this issue Nov 18, 2017 · 1 comment

Comments

@fc-io
Copy link

fc-io commented Nov 18, 2017

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.

field.resolve = function() {
const [source, _, context, info] = arguments;
let promise = oldResolve.call(field, ...arguments);
const isPrimitive = !(promise instanceof Promise);

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)
@giautm
Copy link

giautm commented Nov 22, 2017

        const oldResolve = field.resolve || defaultFieldResolver;

@fc-io : shorten. :D

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