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/loud-rivers-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/graphql": major
---

Removal of the following exports: `Neo4jGraphQLAuthenticationError`, `Neo4jGraphQLForbiddenError`, `EventMeta`, `Neo4jGraphQLAuthPlugin` and `RelationField`. This are either redundant, or internals which shouldn't have been exported.
7 changes: 1 addition & 6 deletions packages/graphql/src/classes/Neo4jGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { mergeResolvers, mergeTypeDefs } from "@graphql-tools/merge";
import Debug from "debug";
import type {
CypherQueryOptions,
Neo4jGraphQLPlugins,
Neo4jFeaturesSettings,
StartupValidationConfig,
ContextFeatures,
Expand Down Expand Up @@ -75,7 +74,6 @@ export interface Neo4jGraphQLConstructor {
features?: Neo4jFeaturesSettings;
config?: Neo4jGraphQLConfig;
driver?: Driver;
plugins?: Neo4jGraphQLPlugins;
}

export const defaultValidationConfig: ValidationConfig = {
Expand All @@ -94,7 +92,6 @@ class Neo4jGraphQL {

private _nodes?: Node[];
private _relationships?: Relationship[];
private plugins?: Neo4jGraphQLPlugins;

private jwtFieldsMap?: Map<string, string>;

Expand All @@ -111,11 +108,10 @@ class Neo4jGraphQL {
private authorization?: Neo4jGraphQLAuthorization;

constructor(input: Neo4jGraphQLConstructor) {
const { config = {}, driver, plugins, features, typeDefs, resolvers } = input;
const { config = {}, driver, features, typeDefs, resolvers } = input;

this.driver = driver;
this.config = config;
this.plugins = plugins;
this.features = this.parseNeo4jFeatures(features);

this.typeDefs = typeDefs;
Expand Down Expand Up @@ -313,7 +309,6 @@ class Neo4jGraphQL {
nodes: this.nodes,
relationships: this.relationships,
schemaModel: this.schemaModel,
plugins: this.plugins,
features: this.features,
authorization: this.authorization,
jwtPayloadFieldsMap: this.jwtFieldsMap,
Expand Down
39 changes: 25 additions & 14 deletions packages/graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,41 @@
* limitations under the License.
*/

import { Neo4jGraphQL, Neo4jGraphQLConstructor } from "./classes";
import { Neo4jGraphQLContext } from "./types/neo4j-graphql-context";

import { CartesianPoint } from "./graphql/objects/CartesianPoint";
import { Point } from "./graphql/objects/Point";
import * as directives from "./graphql/directives";
import * as scalars from "./graphql/scalars";
const objects = { Point, CartesianPoint };

export {
Neo4jGraphQL,
Neo4jGraphQLAuthenticationError,
Neo4jGraphQLConstructor,
Neo4jGraphQLForbiddenError,
} from "./classes";
export * as directives from "./graphql/directives";
export * as scalars from "./graphql/scalars";
export {
import {
DeleteInfo,
EventMeta,
GraphQLOptionsArg,
GraphQLSortArg,
GraphQLWhereArg,
Neo4jGraphQLAuthPlugin,
Neo4jGraphQLSubscriptionsMechanism,
Node,
RelationField,
SubscriptionsEvent,
} from "./types";

export { Neo4jGraphQLContext } from "./types/neo4j-graphql-context";
/**
* Core library functionality.
*/
export { Neo4jGraphQL, Neo4jGraphQLConstructor, Neo4jGraphQLContext };

/**
* Library built-in GraphQL types.
*/
export { directives, scalars, objects };

export const objects = { Point, CartesianPoint };
/**
* Exports for usage by the OGM.
*/
export { DeleteInfo, GraphQLOptionsArg, GraphQLSortArg, GraphQLWhereArg, Node };

/**
* Allows for the implementation of custom subscriptions mechanisms.
*/
export { Neo4jGraphQLSubscriptionsMechanism, SubscriptionsEvent };
7 changes: 2 additions & 5 deletions packages/graphql/src/schema/resolvers/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getNeo4jDatabaseInfo } from "../../classes/Neo4jDatabaseInfo";
import { Executor } from "../../classes/Executor";
import type { ExecutorConstructorParam } from "../../classes/Executor";
import { AUTH_FORBIDDEN_ERROR, DEBUG_GRAPHQL } from "../../constants";
import type { Context, ContextFeatures, Neo4jGraphQLPlugins } from "../../types";
import type { Context, ContextFeatures } from "../../types";
import type { SubscriptionConnectionContext, SubscriptionContext } from "./subscriptions/types";
import type { Neo4jGraphQLSchemaModel } from "../../schema-model/Neo4jGraphQLSchemaModel";
import Cypher from "@neo4j/cypher-builder";
Expand All @@ -43,7 +43,6 @@ export type WrapResolverArguments = {
relationships: Relationship[];
jwtPayloadFieldsMap?: Map<string, string>;
schemaModel: Neo4jGraphQLSchemaModel;
plugins?: Neo4jGraphQLPlugins;
dbInfo?: Neo4jDatabaseInfo;
features: ContextFeatures;
authorization?: Neo4jGraphQLAuthorization;
Expand All @@ -59,7 +58,6 @@ export const wrapResolver =
relationships,
jwtPayloadFieldsMap,
schemaModel,
plugins,
dbInfo,
authorization,
features,
Expand Down Expand Up @@ -93,7 +91,6 @@ export const wrapResolver =
context.nodes = nodes;
context.relationships = relationships;
context.schemaModel = schemaModel;
context.plugins = plugins || {};
context.subscriptionsEnabled = Boolean(features.subscriptions);
context.callbacks = callbacks;
context.features = features;
Expand Down Expand Up @@ -140,7 +137,7 @@ export const wrapResolver =

executorConstructorParam.cypherQueryOptions = context.cypherQueryOptions || config.cypherQueryOptions;

executorConstructorParam.sessionConfig = context.sessionConfig
executorConstructorParam.sessionConfig = context.sessionConfig;

context.executor = new Executor(executorConstructorParam);

Expand Down
19 changes: 0 additions & 19 deletions packages/graphql/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface Context extends Neo4jGraphQLContext {
schemaModel: Neo4jGraphQLSchemaModel;
schema: GraphQLSchema;
callbacks?: Neo4jGraphQLCallbacks;
plugins?: Neo4jGraphQLPlugins;
features: ContextFeatures;
subscriptionsEnabled: boolean;
executor: Executor;
Expand Down Expand Up @@ -318,20 +317,6 @@ export type StartupValidationConfig = StartupValidationOptions | boolean;
/** Input field for graphql-compose */
export type InputField = { type: string; defaultValue?: string; directives?: Directive[] } | string;

export interface Neo4jGraphQLAuthPlugin {
rolesPath?: string;
isGlobalAuthenticationEnabled?: boolean;
bindPredicate?: "all" | "any";

decode<T>(token: string): Promise<T | undefined>;
/**
* This function tries to resolve public or secret keys.
* The implementation on how to resolve the keys by the `JWKSEndpoint` or by the `Secret` is set on when the plugin is being initiated.
* @param req
*/
tryToResolveKeys(req: unknown): void;
}

/** Raw event metadata returned from queries */
export type NodeSubscriptionMeta = {
event: "create" | "update" | "delete";
Expand Down Expand Up @@ -444,10 +429,6 @@ export interface Neo4jGraphQLSubscriptionsMechanism {
init?(): Promise<void>;
}

export interface Neo4jGraphQLPlugins {
auth?: Neo4jGraphQLAuthPlugin;
}

export type CallbackReturnValue = string | number | boolean | undefined | null;

export type Neo4jGraphQLCallback = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { gql } from "graphql-tag";
import { graphql } from "graphql";
import type { Driver } from "neo4j-driver";
import { Neo4jGraphQL } from "../../../src";
import type { EventMeta } from "../../../src";
import { Neo4jGraphQLSubscriptionsDefaultMechanism } from "../../../src/classes/Neo4jGraphQLSubscriptionsDefaultMechanism";
import { UniqueType } from "../../utils/graphql-types";
import Neo4j from "../neo4j";
import type { EventMeta } from "../../../src/types";

describe("Subscriptions Single Instance Plugin", () => {
let driver: Driver;
Expand Down
2 changes: 1 addition & 1 deletion packages/ogm/src/classes/OGM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { Neo4jGraphQLConstructor, Node } from "@neo4j/graphql";
import { Neo4jGraphQL } from "@neo4j/graphql";
import type { GraphQLSchema } from "graphql";
import Model from "./Model";
import { filterDocument } from "../utils";
import { filterDocument } from "../utils/filter-document";
import type { Driver, SessionConfig } from "neo4j-driver";

export interface OGMConstructor extends Neo4jGraphQLConstructor {
Expand Down
3 changes: 1 addition & 2 deletions packages/ogm/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import * as fs from "fs";
import * as graphql from "graphql";
import prettier from "prettier";
import type { OGM } from "./index";
import { getReferenceNode } from "./utils";
import { upperFirst } from "./utils/upper-first";

export interface IGenerateOptions {
Expand Down Expand Up @@ -123,7 +122,7 @@ function createAggregationInput({

function hasConnectOrCreate(node: any, ogm: OGM): boolean {
for (const relation of node.relationFields) {
const refNode = getReferenceNode(ogm, relation);
const refNode = ogm.nodes.find((x) => x.name === relation.typeMeta.name);
if (refNode && refNode.uniqueFields.length > 0) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ogm/src/utils/filter-document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { print } from "graphql";
import filterDocument from "./filter-document";
import { filterDocument } from "./filter-document";

describe("filterDocument", () => {
test("should remove all directives", () => {
Expand Down
19 changes: 7 additions & 12 deletions packages/ogm/src/utils/filter-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
* limitations under the License.
*/

import {
Kind,
type DefinitionNode,
type DocumentNode,
type FieldDefinitionNode,
} from "graphql";
import { Kind, type DefinitionNode, type DocumentNode, type FieldDefinitionNode } from "graphql";
import type { Neo4jGraphQLConstructor } from "@neo4j/graphql";
import { mergeTypeDefs } from "@graphql-tools/merge";

Expand All @@ -43,7 +38,7 @@ const excludedDirectives = [
"settable",
];

function filterDocument(typeDefs: Neo4jGraphQLConstructor["typeDefs"]): DocumentNode {
export function filterDocument(typeDefs: Neo4jGraphQLConstructor["typeDefs"]): DocumentNode {
// hack to keep aggregation enabled for OGM
const schemaExtension = `
extend schema @query(read: true, aggregate: true)
Expand Down Expand Up @@ -90,9 +85,11 @@ function filterDocument(typeDefs: Neo4jGraphQLConstructor["typeDefs"]): Document
?.filter((x) => !excludedDirectives.includes(x.name.value))
.map((x) => {
if (x.name.value === "relationship") {
const args = (x.arguments ? x.arguments?.filter(
(arg) => arg.name.value !== "aggregate"
) : []) as any[]; // cast to any as this type is changing between GraphQL versions
const args = (
x.arguments
? x.arguments?.filter((arg) => arg.name.value !== "aggregate")
: []
) as any[]; // cast to any as this type is changing between GraphQL versions
args?.push(relationshipAggregateArgument);
return {
...x,
Expand All @@ -110,5 +107,3 @@ function filterDocument(typeDefs: Neo4jGraphQLConstructor["typeDefs"]): Document
}, []),
};
}

export default filterDocument;
27 changes: 0 additions & 27 deletions packages/ogm/src/utils/index.ts

This file was deleted.