Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.x' into aggregation-7
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Feb 25, 2025
2 parents 65a995e + c3bed9c commit 7e18b7d
Show file tree
Hide file tree
Showing 332 changed files with 4,852 additions and 2,357 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-balloons-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": major
---

Remove `publish` method from `Neo4jGraphQLSubscriptionsEngine` interface as it is no longer used with CDC-based subscriptions. Implementing this method on custom engines will no longer have an effect, and it is no longer possible to call `publish` directly on `Neo4jGraphQLSubscriptionsCDCEngine`
34 changes: 34 additions & 0 deletions .changeset/kind-clocks-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"@neo4j/graphql": major
---

Sets addVersionPrefix to true by default, this will prepend the Cypher version to all queries by default, ensuring that the correct Cypher version is used in Neo4j:

```cypher
CYPHER 5
MATCH(this:Movie)
```

This may be incompatible with older versions of Neo4j and can be disabled by setting `cypherQueryOption.addVersionPrefix` in the context to false:

```js
{
cypherQueryOptions: {
addVersionPrefix: true,
},
}
```

For example, for an apollo server:

```js
await startStandaloneServer(server, {
context: async ({ req }) => ({
req,
cypherQueryOptions: {
addVersionPrefix: false,
},
}),
listen: { port: 4000 },
});
```
3 changes: 3 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"changesets": [
"beige-poets-move",
"calm-balloons-argue",
"chatty-plants-dress",
"clean-hairs-pretend",
"clever-tomatoes-float",
Expand All @@ -21,6 +22,7 @@
"green-jobs-jam",
"healthy-swans-shave",
"khaki-roses-raise",
"kind-clocks-tickle",
"little-lemons-fail",
"loud-phones-march",
"nine-games-clap",
Expand All @@ -37,6 +39,7 @@
"tame-melons-confess",
"ten-starfishes-attend",
"thick-dogs-provide",
"two-boxes-cheer",
"unlucky-spoons-trade"
]
}
5 changes: 5 additions & 0 deletions .changeset/two-boxes-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": patch
---

Allow `app` to be overwritten in transaction metadata
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@apollo/server": "^4.7.0",
"@graphql-tools/wrap": "^10.0.0",
"@neo4j/graphql": "^7.0.0-alpha.2",
"@neo4j/graphql": "^7.0.0-alpha.3",
"graphql": "16.10.0",
"graphql-tag": "^2.12.6",
"neo4j-driver": "^5.8.0"
Expand Down
41 changes: 41 additions & 0 deletions packages/graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# @neo4j/graphql

## 7.0.0-alpha.3

### Major Changes

- [#5997](https://github.com/neo4j/graphql/pull/5997) [`a716ef8`](https://github.com/neo4j/graphql/commit/a716ef8ec858aa8c6b51c285b3e2d899254c83fe) Thanks [@angrykoala](https://github.com/angrykoala)! - Remove `publish` method from `Neo4jGraphQLSubscriptionsEngine` interface as it is no longer used with CDC-based subscriptions. Implementing this method on custom engines will no longer have an effect, and it is no longer possible to call `publish` directly on `Neo4jGraphQLSubscriptionsCDCEngine`

- [#5976](https://github.com/neo4j/graphql/pull/5976) [`7ddde75`](https://github.com/neo4j/graphql/commit/7ddde75d9828c737e3849c49b6b91f4b2b9b8044) Thanks [@angrykoala](https://github.com/angrykoala)! - Sets addVersionPrefix to true by default, this will prepend the Cypher version to all queries by default, ensuring that the correct Cypher version is used in Neo4j:

```cypher
CYPHER 5
MATCH(this:Movie)
```
This may be incompatible with older versions of Neo4j and can be disabled by setting `cypherQueryOption.addVersionPrefix` in the context to false:
```js
{
cypherQueryOptions: {
addVersionPrefix: true,
},
}
```
For example, for an apollo server:
```js
await startStandaloneServer(server, {
context: async ({ req }) => ({
req,
cypherQueryOptions: {
addVersionPrefix: false,
},
}),
listen: { port: 4000 },
});
```
### Patch Changes
- [#6007](https://github.com/neo4j/graphql/pull/6007) [`48aec51`](https://github.com/neo4j/graphql/commit/48aec512b4707d9b9aa74f05d382eb6980e08971) Thanks [@darrellwarde](https://github.com/darrellwarde)! - Allow `app` to be overwritten in transaction metadata
## 7.0.0-alpha.2
### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neo4j/graphql",
"version": "7.0.0-alpha.2",
"version": "7.0.0-alpha.3",
"description": "A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations",
"keywords": [
"neo4j",
Expand Down
5 changes: 3 additions & 2 deletions packages/graphql/src/classes/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export class Executor {
}

private getCypherVersionStatement(): string {
if (this.cypherQueryOptions?.addVersionPrefix) {
const addVersionPrefixDefault=true
if (this.cypherQueryOptions?.addVersionPrefix ?? addVersionPrefixDefault) {
return `CYPHER ${SUPPORTED_CYPHER_VERSION}\n`;
}
return "";
Expand All @@ -208,8 +209,8 @@ export class Executor {
private getTransactionConfig(info?: GraphQLResolveInfo): TransactionConfig {
const transactionConfig: TransactionConfig = {
metadata: {
...this.transactionMetadata,
app: APP_ID,
...this.transactionMetadata,
type: "user-transpiled",
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { Driver, QueryConfig } from "neo4j-driver";
import { Memoize } from "typescript-memoize";
import { APP_ID } from "../../constants";
import type { Neo4jGraphQLSchemaModel } from "../../schema-model/Neo4jGraphQLSchemaModel";
import type { Neo4jGraphQLSubscriptionsEngine, SubscriptionEngineContext, SubscriptionsEvent } from "../../types";
import type { Neo4jGraphQLSubscriptionsEngine, SubscriptionEngineContext } from "../../types";
import { CDCApi } from "./cdc/cdc-api";
import { CDCEventParser } from "./cdc/cdc-event-parser";

Expand Down Expand Up @@ -65,10 +65,6 @@ export class Neo4jGraphQLSubscriptionsCDCEngine implements Neo4jGraphQLSubscript
return this._parser;
}

public publish(_eventMeta: SubscriptionsEvent): void | Promise<void> {
// Disable Default Publishing mechanism
}

public async init({ schemaModel }: SubscriptionEngineContext): Promise<void> {
await this.cdcApi.updateCursor();
this._parser = new CDCEventParser(schemaModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/

import { astFromDirective, astFromInputObjectType } from "@graphql-tools/utils";
import type { TypeDefinitionNode, DirectiveDefinitionNode } from "graphql";
import type { DirectiveDefinitionNode, TypeDefinitionNode } from "graphql";
import {
GraphQLString,
GraphQLSchema,
DirectiveLocation,
GraphQLBoolean,
GraphQLDirective,
GraphQLInputObjectType,
GraphQLList,
GraphQLBoolean,
DirectiveLocation,
GraphQLSchema,
GraphQLString,
} from "graphql";
import {
AUTHORIZATION_FILTER_OPERATION,
Expand Down
5 changes: 0 additions & 5 deletions packages/graphql/src/graphql/directives/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ export const vectorDirective = new GraphQLDirective({
provider: {
type: VectorProviderEnum,
},
// callback: {
// description:
// "The name of the callback function that will be used to populate the fields values.",
// type: GraphQLString,
// },
},
})
)
Expand Down
95 changes: 95 additions & 0 deletions packages/graphql/src/schema/validation/Neo4jValidationContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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 { Maybe } from "@graphql-tools/utils";
import type {
DefinitionNode,
DocumentNode,
EnumTypeDefinitionNode,
GraphQLError,
GraphQLSchema,
InterfaceTypeDefinitionNode,
InterfaceTypeExtensionNode,
ObjectTypeDefinitionNode,
ObjectTypeExtensionNode,
UnionTypeDefinitionNode,
UnionTypeExtensionNode,
} from "graphql";
import { Kind } from "graphql";
import { SDLValidationContext } from "graphql/validation/ValidationContext";

export type TypeMapWithExtensions = Record<
string,
{
extensions: (ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode)[];
definition:
| ObjectTypeDefinitionNode
| InterfaceTypeDefinitionNode
| UnionTypeDefinitionNode
| EnumTypeDefinitionNode;
}
>;
export class Neo4jValidationContext extends SDLValidationContext {
public readonly typeMapWithExtensions?: TypeMapWithExtensions;
public readonly callbacks?: any;
constructor(
ast: DocumentNode,
schema: Maybe<GraphQLSchema>,
onError: (error: GraphQLError) => void,
callbacks?: any
) {
super(ast, schema, onError);
this.callbacks = callbacks;
this.typeMapWithExtensions = buildTypeMapWithExtensions(ast.definitions);
}
}

// build a type map to access specific types and their extensions
function buildTypeMapWithExtensions(definitions: Readonly<DefinitionNode[]>): TypeMapWithExtensions {
return definitions.reduce((acc, def): TypeMapWithExtensions => {
if (
def.kind === Kind.OBJECT_TYPE_DEFINITION ||
def.kind === Kind.INTERFACE_TYPE_DEFINITION ||
def.kind === Kind.UNION_TYPE_DEFINITION ||
def.kind === Kind.ENUM_TYPE_DEFINITION ||
def.kind === Kind.OBJECT_TYPE_EXTENSION ||
def.kind === Kind.INTERFACE_TYPE_EXTENSION ||
def.kind === Kind.UNION_TYPE_EXTENSION
) {
const typeName = def.name.value;
if (!acc[typeName]) {
acc[typeName] = { extensions: [], definition: undefined };
}
if (
def.kind === Kind.OBJECT_TYPE_EXTENSION ||
def.kind === Kind.INTERFACE_TYPE_EXTENSION ||
def.kind === Kind.UNION_TYPE_EXTENSION
) {
if (acc[typeName].extensions) {
acc[typeName].extensions.push(def);
} else {
acc[typeName].extensions = [def];
}
} else {
acc[typeName].definition = def;
}
}
return acc;
}, {});
}
Loading

0 comments on commit 7e18b7d

Please sign in to comment.