graphql: Custom resolver not found after migration from @computed to @customResolver

Describe the bug After the migration from the @computed directive to the @customResolver directive it throws an error Error: Custom resolver for status has not been provided.

The only change is from status: InvitationStatus! @computed(from: ["createdAt", "isAccepted"]) to status: InvitationStatus! @customResolver(requires: ["createdAt", "isAccepted"]).

Type definitions

Part of the type definition:

const invitation = gql`
  type Invitation @exclude {
    id: ID! @id
    invitedEmail: String!
    isAccepted: Boolean! @default(value: false) @readonly
    isInvited: [User!]! @relationship(type: "IS_INVITED", direction: IN)
    invitedBy: User! @relationship(type: "INVITED_BY", direction: IN) @private
    invitedTo: Project @relationship(type: "INVITED_TO", direction: IN)

    status: InvitationStatus! @customResolver(requires: ["createdAt", "isAccepted"])

    createdAt: DateTime! @timestamp(operations: [CREATE])
    updatedAt: DateTime! @timestamp(operations: [CREATE, UPDATE])
  }

  enum InvitationStatus {
    PENDING
    ACCEPTED
    EXPIRED
  }
`;

Part of the resolvers:

const resolvers = {
  ...

  Invitation: { status },
};

To Reproduce Steps to reproduce the behavior:

  1. Run a server with the typeDefs and resolvers above (resolver function is not included in the code snippets)
  2. The following error message is thrown:
/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-custom-resolver-meta.js:44
        throw new Error(`Custom resolver for ${field.name.value} has not been provided`);
              ^

Error: Custom resolver for status has not been provided
    at getCustomResolverMeta (/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-custom-resolver-meta.js:44:15)
    at obj.fields.reduce.relationFields (/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-obj-field-meta.js:59:75)
    at Array.reduce (<anonymous>)
    at getObjFieldMeta (/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-obj-field-meta.js:44:25)
    at /Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-nodes.js:82:61
    at Array.map (<anonymous>)
    at getNodes (/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/get-nodes.js:39:47)
    at makeAugmentedSchema (/Users/user/code/api/node_modules/@neo4j/graphql/dist/schema/make-augmented-schema.js:128:52)
    at /Users/user/code/api/node_modules/@neo4j/graphql/dist/classes/Neo4jGraphQL.js:155:100
    at new Promise (<anonymous>)

Expected behavior The app runs without throwing the error.

Screenshots Not needed.

System (please complete the following information):

  • OS: macOS
  • Version:
    "@neo4j/graphql": "^3.0.3",
    "@neo4j/graphql-ogm": "^3.0.3",
    "@neo4j/graphql-plugin-auth": "^1.0.0",
    "neo4j-driver": "^5.0.1"
  • Node.js version: v16.17.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

Hi @lukasbals, glad you found a solution!

To be honest I’m not entirely sure as I’m not too familiar with the OGM but I’ll bring this up with the team.

Thanks!

@tbwiss This would fix the issue. But I would rather skip the validation on the ORM initialization and not on the Neo4jGraphql initialization.