Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/big-crabs-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": major
---

The deprecated `@callback` directive has been removed. Any remaining usages of `@callback` should be replaced with `@populatedBy`. See https://github.com/neo4j/graphql/blob/dev/docs/modules/ROOT/pages/guides/v4-migration/index.adoc#callback-renamed-to-populatedby for more information.
8 changes: 0 additions & 8 deletions docs/modules/ROOT/pages/directives.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ The `@auth` directive is used to define complex fine-grained and role-based acce

Reference: xref::auth/auth-directive.adoc[`@auth` directive]

== `@callback`

NOTE: The `@callback` directive has been deprecated and will be removed in version 4.0. Please use the xref::directives.adoc#populated-by-directive[`@populatedBy` directive] instead.

The `@callback` directive is used to specify a function that will be invoked when updating or creating the properties on a node or relationship.

Reference: xref::type-definitions/autogeneration.adoc#type-definitions-autogeneration-callback[`@callback`]

== `@coalesce`

The `@coalesce` directive exposes a mechanism for querying against non-existent, `null` values on a node.
Expand Down
10 changes: 0 additions & 10 deletions docs/modules/ROOT/pages/type-definitions/autogeneration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ new Neo4jGraphQL({

NOTE: The second positional argument, in this case `_args`, has a type of `Record<string, never>`, and as such will always be an empty object.


[[type-definitions-autogeneration-callback]]
== `@callback`

NOTE: The `@callback` directive has been deprecated and will be removed in version 4.0. Please use xref::type-definitions/autogeneration.adoc#type-definitions-autogeneration-populated-by[`@populatedBy`] instead.

The `@callback` directive is used to specify a function that will be invoked when updating or creating the properties on a node or relationship.

For non-required values, callbacks may return `undefined` (meaning that nothing will be changed or added to the property) or `null` (meaning that the property will be removed).

=== Definition

[source, graphql, indent=0]
Expand Down
46 changes: 0 additions & 46 deletions packages/graphql/src/graphql/directives/callback.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/graphql/src/graphql/directives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

export { aliasDirective } from "./alias";
export { callbackDirective } from "./callback";
export { coalesceDirective } from "./coalesce";
export { customResolverDirective } from "./customResolver";
export { cypherDirective } from "./cypher";
Expand Down
19 changes: 1 addition & 18 deletions packages/graphql/src/schema/get-obj-field-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ import type {
import parseValueNode from "./parse-value-node";
import checkDirectiveCombinations from "./check-directive-combinations";
import { upperFirst } from "../utils/upper-first";
import { getCallbackMeta, getPopulatedByMeta } from "./get-populated-by-meta";

const deprecationWarning =
"The @callback directive has been deprecated and will be removed in version 4.0. Please use @populatedBy instead." +
"More information can be found at " +
"https://neo4j.com/docs/graphql-manual/current/guides/v4-migration/#_callback_renamed_to_populatedby.";
import { getPopulatedByMeta } from "./get-populated-by-meta";

export interface ObjectFields {
relationFields: RelationField[];
Expand All @@ -84,8 +79,6 @@ export interface ObjectFields {
customResolverFields: CustomResolverField[];
}

let callbackDeprecatedWarningShown = false;

function getObjFieldMeta({
obj,
objects,
Expand Down Expand Up @@ -149,7 +142,6 @@ function getObjFieldMeta({
const coalesceDirective = directives.find((x) => x.name.value === "coalesce");
const timestampDirective = directives.find((x) => x.name.value === "timestamp");
const aliasDirective = directives.find((x) => x.name.value === "alias");
const callbackDirective = directives.find((x) => x.name.value === "callback");
const populatedByDirective = directives.find((x) => x.name.value === "populatedBy");

const unique = getUniqueMeta(directives, obj, field.name.value);
Expand Down Expand Up @@ -504,15 +496,6 @@ function getObjFieldMeta({
primitiveField.callback = callback;
}

if (callbackDirective) {
if (!callbackDeprecatedWarningShown) {
console.warn(deprecationWarning);
callbackDeprecatedWarningShown = true;
}
const callback = getCallbackMeta(callbackDirective, callbacks);
primitiveField.callback = callback;
}

if (idDirective) {
const autogenerate = idDirective.arguments?.find((a) => a.name.value === "autogenerate");
if (!autogenerate || (autogenerate.value as BooleanValueNode).value) {
Expand Down
19 changes: 0 additions & 19 deletions packages/graphql/src/schema/get-populated-by-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@
import type { DirectiveNode, ArgumentNode, ListValueNode, StringValueNode } from "graphql";
import type { Callback, CallbackOperations, Neo4jGraphQLCallbacks } from "../types";

/** Deprecated in favour of populatedBy */
export function getCallbackMeta(directive: DirectiveNode, callbacks?: Neo4jGraphQLCallbacks): Callback {
const operationsArg = directive.arguments?.find((x) => x.name.value === "operations") as ArgumentNode;
const nameArg = directive.arguments?.find((x) => x.name.value === "name") as ArgumentNode;

const operationsList = operationsArg.value as ListValueNode;
const operations = operationsList.values.map((value) => (value as StringValueNode).value) as CallbackOperations[];
const callbackName = (nameArg.value as StringValueNode).value;

if (typeof (callbacks || {})[callbackName] !== "function") {
throw new Error(`Directive callback '${callbackName}' must be of type function`);
}

return {
operations,
callbackName,
};
}

export function getPopulatedByMeta(directive: DirectiveNode, callbacks?: Neo4jGraphQLCallbacks): Callback {
const operationsArg = directive.arguments?.find((x) => x.name.value === "operations") as ArgumentNode;
const callbackArg = directive.arguments?.find((x) => x.name.value === "callback") as ArgumentNode;
Expand Down
129 changes: 0 additions & 129 deletions packages/graphql/tests/integration/deprecated/1414.int.test.ts

This file was deleted.

Loading