-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/7.x' into aggregation-7
- Loading branch information
Showing
332 changed files
with
4,852 additions
and
2,357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
packages/graphql/src/schema/validation/Neo4jValidationContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, {}); | ||
} |
Oops, something went wrong.