cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get the callback directive to work?

Hi,

I can't get this to work for some reason:

type BlogPost
  id: ID! @id
  title: String
  slug: @callback(operations: [CREATE, UPDATE], name: "slug") 
const slugCallback = async (root: any) => {
  // console.log("Slug callback", root);
  return "something...";
};
const neoSchema = new Neo4jGraphQL({
  typeDefs,
  driver,
  config: { callbacks: { slug: slugCallback } },
  });

I receive the following error:
{
"name": "TypeError",
"message": "Failed to fetch",
"stack": "TypeError: Failed to fetch\n at
...etc
}

Seems like there's something wrong with the syntax. If I remove the @callback directive, then everything works as expected.

1 REPLY 1

Hello, I think you may be fooled by the docment.
Yes,there is an error in docs.
slug: @callback(operations: [CREATE, UPDATE], name: "slug") should modified to
slug: String @callback(operations: [CREATE, UPDATE], name: "slug")
the above added String or some other type.
If you use ogm.init(). don't forget to pass config option to it too.