From 537b8d494da3dd711cceb42ee037d799cc70d549 Mon Sep 17 00:00:00 2001 From: Darrell Warde Date: Mon, 17 Jul 2023 13:56:13 +0100 Subject: [PATCH 1/2] Un-deprecate `fulltext` argument, add descriptions for different functionality --- .../graphql/src/schema/augment/fulltext.ts | 6 ---- .../src/schema/resolvers/query/aggregate.ts | 11 ++---- .../src/schema/resolvers/query/fulltext.ts | 2 ++ .../src/schema/resolvers/query/read.ts | 11 ++---- .../schema/resolvers/query/root-connection.ts | 11 ++---- .../fulltext/fulltext-argument.int.test.ts} | 10 +++--- ...int.test.ts => fulltext-query.int.test.ts} | 0 .../graphql/tests/schema/fulltext.test.ts | 34 +++++++++++++++++-- 8 files changed, 44 insertions(+), 41 deletions(-) rename packages/graphql/tests/integration/{deprecated/fulltext.int.test.ts => directives/fulltext/fulltext-argument.int.test.ts} (98%) rename packages/graphql/tests/integration/directives/fulltext/{fulltext.int.test.ts => fulltext-query.int.test.ts} (100%) diff --git a/packages/graphql/src/schema/augment/fulltext.ts b/packages/graphql/src/schema/augment/fulltext.ts index 3fe77085bf..4a07f8d8f3 100644 --- a/packages/graphql/src/schema/augment/fulltext.ts +++ b/packages/graphql/src/schema/augment/fulltext.ts @@ -25,12 +25,6 @@ import { FloatWhere } from "../../graphql/input-objects/FloatWhere"; import { upperFirst } from "../../utils/upper-first"; import { fulltextResolver } from "../resolvers/query/fulltext"; -export const fulltextArgDeprecationMessage = - "This argument has been deprecated and will be removed in future versions of the library. " + - "Please use the top-level query that corresponds to the index you wish to query instead. " + - "More information about the changes to @fulltext can be found here: " + - "https://neo4j.com/docs/graphql-manual/current/guides/v4-migration/#_fulltext_changes."; - export function augmentFulltextSchema( node: Node, composer: SchemaComposer, diff --git a/packages/graphql/src/schema/resolvers/query/aggregate.ts b/packages/graphql/src/schema/resolvers/query/aggregate.ts index 2b16105cf9..b76ed9ccc3 100644 --- a/packages/graphql/src/schema/resolvers/query/aggregate.ts +++ b/packages/graphql/src/schema/resolvers/query/aggregate.ts @@ -23,7 +23,6 @@ import type { Node } from "../../../classes"; import type { Context } from "../../../types"; import { translateAggregate } from "../../../translate"; import getNeo4jResolveTree from "../../../utils/get-neo4j-resolve-tree"; -import { fulltextArgDeprecationMessage } from "../../../schema/augment/fulltext"; export function aggregateResolver({ node }: { node: Node }) { async function resolve(_root: any, _args: any, _context: unknown, info: GraphQLResolveInfo) { @@ -57,14 +56,8 @@ export function aggregateResolver({ node }: { node: Node }) { ? { fulltext: { type: `${node.name}Fulltext`, - directives: [ - { - name: "deprecated", - args: { - reason: fulltextArgDeprecationMessage, - }, - }, - ], + description: + "Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score.", }, } : {}), diff --git a/packages/graphql/src/schema/resolvers/query/fulltext.ts b/packages/graphql/src/schema/resolvers/query/fulltext.ts index 08fb24861d..ca8f886d41 100644 --- a/packages/graphql/src/schema/resolvers/query/fulltext.ts +++ b/packages/graphql/src/schema/resolvers/query/fulltext.ts @@ -44,6 +44,8 @@ export function fulltextResolver( return { type: `[${node.fulltextTypeNames.result}!]!`, + description: + "Query a full-text index. This query returns the query score, but does not allow for aggregations. Use the `fulltext` argument under other queries for this functionality.", resolve, args: { phrase: "String!", diff --git a/packages/graphql/src/schema/resolvers/query/read.ts b/packages/graphql/src/schema/resolvers/query/read.ts index 2b8b492dd4..87ffffb925 100644 --- a/packages/graphql/src/schema/resolvers/query/read.ts +++ b/packages/graphql/src/schema/resolvers/query/read.ts @@ -23,7 +23,6 @@ import { translateRead } from "../../../translate"; import type { Node } from "../../../classes"; import type { Context } from "../../../types"; import getNeo4jResolveTree from "../../../utils/get-neo4j-resolve-tree"; -import { fulltextArgDeprecationMessage } from "../../../schema/augment/fulltext"; export function findResolver({ node }: { node: Node }) { async function resolve(_root: any, args: any, _context: unknown, info: GraphQLResolveInfo) { @@ -52,14 +51,8 @@ export function findResolver({ node }: { node: Node }) { ? { fulltext: { type: `${node.name}Fulltext`, - directives: [ - { - name: "deprecated", - args: { - reason: fulltextArgDeprecationMessage, - }, - }, - ], + description: + "Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score.", }, } : {}), diff --git a/packages/graphql/src/schema/resolvers/query/root-connection.ts b/packages/graphql/src/schema/resolvers/query/root-connection.ts index 3f1c14c2fb..26a9ceaca2 100644 --- a/packages/graphql/src/schema/resolvers/query/root-connection.ts +++ b/packages/graphql/src/schema/resolvers/query/root-connection.ts @@ -28,7 +28,6 @@ import type { Context } from "../../../types"; import getNeo4jResolveTree from "../../../utils/get-neo4j-resolve-tree"; import { isNeoInt } from "../../../utils/utils"; import { createConnectionWithEdgeProperties } from "../../pagination"; -import { fulltextArgDeprecationMessage } from "../../../schema/augment/fulltext"; import { graphqlDirectivesToCompose } from "../../to-compose"; export function rootConnectionResolver({ node, composer }: { node: Node; composer: SchemaComposer }) { @@ -120,14 +119,8 @@ export function rootConnectionResolver({ node, composer }: { node: Node; compose ? { fulltext: { type: `${node.name}Fulltext`, - directives: [ - { - name: "deprecated", - args: { - reason: fulltextArgDeprecationMessage, - }, - }, - ], + description: + "Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score.", }, } : {}), diff --git a/packages/graphql/tests/integration/deprecated/fulltext.int.test.ts b/packages/graphql/tests/integration/directives/fulltext/fulltext-argument.int.test.ts similarity index 98% rename from packages/graphql/tests/integration/deprecated/fulltext.int.test.ts rename to packages/graphql/tests/integration/directives/fulltext/fulltext-argument.int.test.ts index 0fa5199f12..f8a1d667ca 100644 --- a/packages/graphql/tests/integration/deprecated/fulltext.int.test.ts +++ b/packages/graphql/tests/integration/directives/fulltext/fulltext-argument.int.test.ts @@ -21,11 +21,11 @@ import type { Driver } from "neo4j-driver"; import { generate } from "randomstring"; import { graphql } from "graphql"; import { gql } from "graphql-tag"; -import Neo4j from "../neo4j"; -import { Neo4jGraphQL } from "../../../src/classes"; -import { UniqueType } from "../../utils/graphql-types"; -import { delay } from "../../../src/utils/utils"; -import { isMultiDbUnsupportedError } from "../../utils/is-multi-db-unsupported-error"; +import Neo4j from "../../neo4j"; +import { Neo4jGraphQL } from "../../../../src/classes"; +import { UniqueType } from "../../../utils/graphql-types"; +import { delay } from "../../../../src/utils/utils"; +import { isMultiDbUnsupportedError } from "../../../utils/is-multi-db-unsupported-error"; describe("@fulltext directive", () => { let driver: Driver; diff --git a/packages/graphql/tests/integration/directives/fulltext/fulltext.int.test.ts b/packages/graphql/tests/integration/directives/fulltext/fulltext-query.int.test.ts similarity index 100% rename from packages/graphql/tests/integration/directives/fulltext/fulltext.int.test.ts rename to packages/graphql/tests/integration/directives/fulltext/fulltext-query.int.test.ts diff --git a/packages/graphql/tests/schema/fulltext.test.ts b/packages/graphql/tests/schema/fulltext.test.ts index 75dee8768d..e38c4f87e6 100644 --- a/packages/graphql/tests/schema/fulltext.test.ts +++ b/packages/graphql/tests/schema/fulltext.test.ts @@ -190,10 +190,38 @@ describe("@fulltext schema", () => { } type Query { - movies(fulltext: MovieFulltext @deprecated(reason: \\"This argument has been deprecated and will be removed in future versions of the library. Please use the top-level query that corresponds to the index you wish to query instead. More information about the changes to @fulltext can be found here: https://neo4j.com/docs/graphql-manual/current/guides/v4-migration/#_fulltext_changes.\\"), options: MovieOptions, where: MovieWhere): [Movie!]! - moviesAggregate(fulltext: MovieFulltext @deprecated(reason: \\"This argument has been deprecated and will be removed in future versions of the library. Please use the top-level query that corresponds to the index you wish to query instead. More information about the changes to @fulltext can be found here: https://neo4j.com/docs/graphql-manual/current/guides/v4-migration/#_fulltext_changes.\\"), where: MovieWhere): MovieAggregateSelection! - moviesConnection(after: String, first: Int, fulltext: MovieFulltext @deprecated(reason: \\"This argument has been deprecated and will be removed in future versions of the library. Please use the top-level query that corresponds to the index you wish to query instead. More information about the changes to @fulltext can be found here: https://neo4j.com/docs/graphql-manual/current/guides/v4-migration/#_fulltext_changes.\\"), sort: [MovieSort], where: MovieWhere): MoviesConnection! + movies( + \\"\\"\\" + Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score. + \\"\\"\\" + fulltext: MovieFulltext + options: MovieOptions + where: MovieWhere + ): [Movie!]! + moviesAggregate( + \\"\\"\\" + Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score. + \\"\\"\\" + fulltext: MovieFulltext + where: MovieWhere + ): MovieAggregateSelection! + moviesConnection( + after: String + first: Int + \\"\\"\\" + Query a full-text index. Allows for the aggregation of results, but does not return the query score. Use the root full-text query fields if you require the score. + \\"\\"\\" + fulltext: MovieFulltext + sort: [MovieSort] + where: MovieWhere + ): MoviesConnection! + \\"\\"\\" + Query a full-text index. This query returns the query score, but does not allow for aggregations. Use the \`fulltext\` argument under other queries for this functionality. + \\"\\"\\" moviesFulltextMovieDescription(limit: Int, offset: Int, phrase: String!, sort: [MovieFulltextSort!], where: MovieFulltextWhere): [MovieFulltextResult!]! + \\"\\"\\" + Query a full-text index. This query returns the query score, but does not allow for aggregations. Use the \`fulltext\` argument under other queries for this functionality. + \\"\\"\\" moviesFulltextMovieTitle(limit: Int, offset: Int, phrase: String!, sort: [MovieFulltextSort!], where: MovieFulltextWhere): [MovieFulltextResult!]! } From 93b11b80063630f2986dc2515555e0f012ade501 Mon Sep 17 00:00:00 2001 From: Darrell Warde Date: Mon, 17 Jul 2023 14:39:12 +0100 Subject: [PATCH 2/2] Update snapshot --- packages/ogm/src/generate.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ogm/src/generate.test.ts b/packages/ogm/src/generate.test.ts index 6ab3606223..6b9f79ae2a 100644 --- a/packages/ogm/src/generate.test.ts +++ b/packages/ogm/src/generate.test.ts @@ -365,6 +365,7 @@ describe("generate", () => { export type Query = { __typename?: \\"Query\\"; + /** Query a full-text index. This query returns the query score, but does not allow for aggregations. Use the \`fulltext\` argument under other queries for this functionality. */ usersFulltextUserName: Array; users: Array; usersConnection: UsersConnection;