Skip to content

no resolver when adding directive to scalar field #1

@fc-io

Description

@fc-io

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions