Socket
Socket
Sign inDemoInstall

@neo4j/introspector

Package Overview
Dependencies
14
Maintainers
7
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 2.0.0-beta.0

6

dist/transforms/neo4j-graphql/directives/Node.d.ts
import type { Directive } from "../types";
export declare class NodeDirective implements Directive {
label?: string;
additionalLabels: string[];
addLabel(label: string): void;
addAdditionalLabels(labels: string[] | string): void;
labels: string[];
addLabels(labels: string[]): void;
toString(): string;
}
//# sourceMappingURL=Node.d.ts.map

@@ -24,22 +24,12 @@ "use strict";

constructor() {
this.additionalLabels = [];
this.labels = [];
}
addLabel(label) {
this.label = label;
}
addAdditionalLabels(labels) {
addLabels(labels) {
if (!labels.length) {
return;
}
this.additionalLabels = this.additionalLabels.concat(labels);
this.labels = this.labels.concat(labels);
}
toString() {
const directiveArguments = [];
if (this.label) {
directiveArguments.push(`label: "${this.label}"`);
}
if (this.additionalLabels.length) {
directiveArguments.push(`additionalLabels: ["${this.additionalLabels.join('","')}"]`);
}
return directiveArguments.length ? `@node(${directiveArguments.join(", ")})` : "";
return this.labels.length ? `@node(labels: ["${this.labels.join('", "')}"])` : "";
}

@@ -46,0 +36,0 @@ }

@@ -60,6 +60,5 @@ "use strict";

const nodeDirective = new Node_1.NodeDirective();
if (mainLabel !== uniqueTypeName) {
nodeDirective.addLabel(mainLabel);
if (neo4jNode.labels.length > 1 || mainLabel !== uniqueTypeName) {
nodeDirective.addLabels(neo4jNode.labels);
}
nodeDirective.addAdditionalLabels(neo4jNode.labels.slice(1));
if (nodeDirective.toString().length) {

@@ -66,0 +65,0 @@ node.addDirective(nodeDirective);

{
"name": "@neo4j/introspector",
"version": "1.0.3",
"version": "2.0.0-beta.0",
"description": "Introspect a Neo4j database model/schema",

@@ -24,2 +24,5 @@ "keywords": [

],
"engines": {
"node": ">=16.0.0"
},
"scripts": {

@@ -37,9 +40,9 @@ "clean": "cd src/ && tsc --build --clean",

"devDependencies": {
"@neo4j/graphql": "^3.16.0",
"@types/jest": "29.4.0",
"@types/node": "18.11.17",
"@types/pluralize": "0.0.29",
"jest": "29.4.1",
"ts-jest": "29.0.5",
"typescript": "4.9.5"
"@neo4j/graphql": "^4.0.0-beta.0",
"@types/jest": "29.5.3",
"@types/node": "18.15.1",
"@types/pluralize": "0.0.30",
"jest": "29.6.1",
"ts-jest": "29.1.1",
"typescript": "5.1.6"
},

@@ -52,4 +55,4 @@ "dependencies": {

"peerDependencies": {
"neo4j-driver": "^4.1.0 || ^5.0.0"
"neo4j-driver": "^5.8.0"
}
}
# Introspect schema from an existing Neo4j database
This is a tool that enables you, with very little effort, to introspect the schema / data model in an existing Neo4j database and builds up a set of data structures that can be transformed into any output format.
This is a tool that enables you, with very little effort, to introspect the schema/data model in an existing Neo4j database and build up a set of data structures that can be transformed into any output format.

@@ -8,3 +8,3 @@ This is provided by a separate npm package, `@neo4j/introspector`.

The currently officially supported output format is GraphQL type definitions.
This is usually a one-time-thing and should be considered a starting point for a GraphQL schema.
This is usually a one-time thing and should be considered a starting point for a GraphQL schema.

@@ -19,4 +19,4 @@ ## GraphQL Type Definitions format

- `@node`
- `label` for mapping where a node label might use a character that's not in the GraphQL supported character set
- `additionalLabels` for nodes that has multiple labels
- `label` for mapping where a node label might use a character that's not in the supported GraphQL character set
- `additionalLabels` for nodes that have multiple labels
- Generating a read-only version of the GraphQL type definitions, i.e. generate a `@exclude(operations: [CREATE, DELETE, UPDATE])` directive on all node types.

@@ -26,3 +26,3 @@

If an element property has mixed types through out your graph, that property will be excluded from the
If an element property has mixed types throughout your graph, that property will be excluded from the
generated type definitions. The reason for this is that your GraphQL server will throw an error if it

@@ -33,3 +33,3 @@ finds data that doesn't match the specified type.

Currently there's a programmatic API for introspecting the Neo4j schema and generating GraphQL type definitions.
Currently, there's a programmatic API for introspecting the Neo4j schema and generating GraphQL type definitions.

@@ -63,3 +63,3 @@ #### Introspect and persist to file

This example generates a **read-only** version of the schema from the database and immediately spins up an Apollo server.
This example generates a **read-only** version of the schema from the database and immediately spins up an ApolloServer server.

@@ -69,5 +69,7 @@ Here the type definitions are never persisted to disk.

```js
const { Neo4jGraphQL } = require("@neo4j/graphql");
const { toGraphQLTypeDefs } = require("@neo4j/introspector");
const neo4j = require("neo4j-driver");
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { Neo4jGraphQL } from "@neo4j/graphql";
import { toGraphQLTypeDefs } from "@neo4j/introspector";
import neo4j from "neo4j-driver";

@@ -87,5 +89,8 @@ const driver = neo4j.driver("neo4j://localhost:7687", neo4j.auth.basic("neo4j", "password"));

const server = new ApolloServer({
schema: neoSchema.schema,
context: ({ req }) => ({ req }),
schema: await neoSchema.getSchema(),
});
await startStandaloneServer(server, {
context: async ({ req }) => ({ req }),
});
}

@@ -102,4 +107,4 @@ main();

```js
const { toGenericStruct } = require("@neo4j/introspector");
const neo4j = require("neo4j-driver");
import { toGenericStruct } from "@neo4j/introspector";
import neo4j from "neo4j-driver";

@@ -112,3 +117,3 @@ const driver = neo4j.driver("neo4j://localhost:7687", neo4j.auth.basic("neo4j", "password"));

const genericStruct = await toGenericStruct(sessionFactory, readonly);
// Programatically transform to what you need.
// Programmatically transform to what you need.
}

@@ -115,0 +120,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc