Skip to content

Commit

Permalink
Merge pull request #5315 from neo4j/fix-tests
Browse files Browse the repository at this point in the history
Fix tests for version 6.x
  • Loading branch information
angrykoala authored Jul 5, 2024
2 parents 0f2ca3c + feb3343 commit 67d8d80
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 15 deletions.
20 changes: 19 additions & 1 deletion packages/graphql/src/api-v6/queryIRFactory/FilterOperators.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { AttributeAdapter } from "../../schema-model/attribute/model-adapters/AttributeAdapter";
import type { FilterOperator, RelationshipWhereOperator } from "../../translate/queryAST/ast/filters/Filter";

// TODO: remove Adapter dependency in v6
export function getFilterOperator(attribute: AttributeAdapter, operator: string): FilterOperator | undefined {

if (attribute.typeHelper.isString() || attribute.typeHelper.isID()) {
return getStringOperator(operator);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { GraphQLResolveInfo } from "graphql";
import type { PageInfo } from "graphql-relay";
import { createConnectionWithEdgeProperties } from "../../schema/pagination";
Expand Down
19 changes: 19 additions & 0 deletions packages/graphql/src/api-v6/resolvers/global-id-field-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { GraphQLResolveInfo } from "graphql";
import type { ConcreteEntity } from "../../schema-model/entity/ConcreteEntity";
import type { ConnectionQueryArgs } from "../../types";
Expand Down
19 changes: 19 additions & 0 deletions packages/graphql/src/api-v6/resolvers/global-node-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { GraphQLResolveInfo } from "graphql";
import type { ConcreteEntity } from "../../schema-model/entity/ConcreteEntity";
import type { GlobalNodeArgs } from "../../types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { GraphQLBoolean, GraphQLFloat, GraphQLID, GraphQLInt, GraphQLString } from "graphql";
import type { SchemaComposer } from "graphql-compose";
import { ScalarTypeComposer } from "graphql-compose";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { ConcreteEntity } from "../../../schema-model/entity/ConcreteEntity";
import type { StaticSchemaTypes } from "./StaticSchemaTypes";
import type { TopLevelEntitySchemaTypes } from "./TopLevelEntitySchemaTypes";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
import type { GraphQLType } from "graphql";
import { GraphQLList } from "graphql";

export function toGraphQLList<T extends GraphQLType>(type: T): GraphQLList<T> {
export function toGraphQLList<T extends GraphQLType>(type: T): GraphQLList<GraphQLType> {
return new GraphQLList(type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
import type { GraphQLType } from "graphql";
import { GraphQLNonNull } from "graphql";

export function toGraphQLNonNull<T extends GraphQLType>(type: T): GraphQLNonNull<T> {
export function toGraphQLNonNull<T extends GraphQLType>(type: T): GraphQLNonNull<GraphQLType> {
return new GraphQLNonNull(type);
}
10 changes: 5 additions & 5 deletions packages/graphql/src/classes/Subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { buildSubgraphSchema } from "@apollo/subgraph";
import { mergeTypeDefs } from "@graphql-tools/merge";
import type { IResolvers, TypeSource } from "@graphql-tools/utils";
import type {
ConstDirectiveNode,
DirectiveNode,
DocumentNode,
GraphQLDirective,
GraphQLNamedType,
Expand All @@ -30,12 +30,12 @@ import type {
} from "graphql";
import { Kind, parse, print } from "graphql";
import type { Neo4jGraphQLSchemaModel } from "../schema-model/Neo4jGraphQLSchemaModel";
import type { Neo4jGraphQLComposedContext } from "../schema/resolvers/composition/wrap-query-and-mutation";
import { translateResolveReference } from "../translate/translate-resolve-reference";
import type { Neo4jGraphQLTranslationContext } from "../types/neo4j-graphql-translation-context";
import { execute } from "../utils";
import getNeo4jResolveTree from "../utils/get-neo4j-resolve-tree";
import { isInArray } from "../utils/is-in-array";
import type { Neo4jGraphQLComposedContext } from "../schema/resolvers/composition/wrap-query-and-mutation";
import type { Neo4jGraphQLTranslationContext } from "../types/neo4j-graphql-translation-context";
import type { ValueOf } from "../utils/value-of";

// TODO fetch the directive names from the spec
Expand Down Expand Up @@ -189,7 +189,7 @@ export class Subgraph {

private findFederationLinkMeta(
typeDefs: TypeSource
): { extension: SchemaExtensionNode; directive: ConstDirectiveNode } | undefined {
): { extension: SchemaExtensionNode; directive: DirectiveNode } | undefined {
const document = mergeTypeDefs(typeDefs);

for (const definition of document.definitions) {
Expand Down Expand Up @@ -221,7 +221,7 @@ export class Subgraph {
return name.replace("@", "");
}

private parseLinkImportArgument(directive: ConstDirectiveNode): void {
private parseLinkImportArgument(directive: DirectiveNode): void {
const argument = directive.arguments?.find((arg) => arg.name.value === "import");

if (argument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("RelayId projection with alias directive", () => {
type ${Movie} @node {
dbId: ID! @id @unique @relayId @alias(property: "serverId")
title: String!
genre: ${Genre}! @relationship(type: "HAS_GENRE", direction: OUT)
genre: [${Genre}!]! @relationship(type: "HAS_GENRE", direction: OUT)
actors: [${Actor}!]! @relationship(type: "ACTED_IN", direction: OUT)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ describe("Global node query", () => {
const Actor = testHelper.createUniqueType("Actor");

beforeAll(async () => {
const typeDefs = `
const typeDefs = /* GraphQL */ `
type ${Movie} @node {
dbId: ID! @id @unique @relayId
title: String!
genre: ${Genre}! @relationship(type: "HAS_GENRE", direction: OUT)
genre: [${Genre}!]! @relationship(type: "HAS_GENRE", direction: OUT)
actors: [${Actor}!]! @relationship(type: "ACTED_IN", direction: OUT)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("RelayId projection with filters", () => {
type ${Movie} @node {
dbId: ID! @id @unique @relayId
title: String!
genre: ${Genre}! @relationship(type: "HAS_GENRE", direction: OUT)
genre: [${Genre}!]! @relationship(type: "HAS_GENRE", direction: OUT)
actors: [${Actor}!]! @relationship(type: "ACTED_IN", direction: OUT)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ describe("RelayId projection", () => {
const Actor = testHelper.createUniqueType("Actor");

beforeAll(async () => {
const typeDefs = `
const typeDefs = /* GraphQL */ `
type ${Movie} @node {
dbId: ID! @id @unique @relayId
title: String!
genre: ${Genre}! @relationship(type: "HAS_GENRE", direction: OUT)
genre: [${Genre}!]! @relationship(type: "HAS_GENRE", direction: OUT)
actors: [${Actor}!]! @relationship(type: "ACTED_IN", direction: OUT)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Pagination with first and after", () => {
await testHelper.close();
});

test.only("Get movies with first and after argument", async () => {
test("Get movies with first and after argument", async () => {
const afterCursor = offsetToCursor(4);
const query = /* GraphQL */ `
query {
Expand Down

0 comments on commit 67d8d80

Please sign in to comment.