Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

neo4j-graphql-skill

БесплатноБез исполняемых скриптовНе проверен

Build and configure a GraphQL API backed by Neo4j using @neo4j/graphql v7 (current) or v5 (LTS). Covers Neo4jGraphQL constructor, getSchema()…

neo4jот neo4j★ 126 звёзд на GitHub

Об этом скилле

When to Use

  • Creating a GraphQL API from a Neo4j graph schema with @neo4j/graphql
  • Writing type definitions with @relationship, @cypher, @authorization directives
  • Using OGM (v5 only) for server-side programmatic Neo4j access (bypasses GraphQL auth)
  • Configuring auto-generated queries, mutations, subscriptions
  • Securing types/fields with JWT or JWKS-based @authorization rules
  • Migrating from v5/v6 to v7 (breaking changes below)

When NOT to Use

  • Raw Cypher queries outside GraphQL resolvers → neo4j-cypher-skill
  • Spring Data Neo4j / Java entity mapping → neo4j-spring-data-skill
  • Generic GraphQL without Neo4j — outside scope

Version Matrix

Version Status Notes
v7 Current — use ≥ 7.6.4 @node required; options removed; explicit eq syntax
v5 LTS — use ≥ 5.12.15 Older syntax; options: {limit, offset, sort} still valid

Default to v7 unless codebase is on v5. Upgrade past these security patches before shipping auth:

Fix Fixed in
Subscriptions accepted an unverified JWT from WebSocket connectionParams (auth/authz bypass) 7.5.6 / 5.12.14
Field-level @authentication on a root custom-resolver field ignored when the operation type also had type-level @authentication (privilege escalation) 7.6.0 / 5.12.15
@authorization rules not applied on create-relationship operations 7.6.2
Source @authorization rules not applied to source node on delete-relationship 7.6.3
Type-level @authentication not enforced on entities returned by @cypher fields; none quantifier inverted in authorization filters 7.6.4

7.6.5 / 5.12.16 fix Apollo Federation getSubgraphSchema() only. Prefer latest patch.


Step 1 — Install

npm install @neo4j/graphql neo4j-driver graphql @apollo/server

For subscriptions (CDC required):

npm install ws graphql-ws express body-parser cors

Step 2 — Minimal Server Setup

import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { Neo4jGraphQL } from '@neo4j/graphql';
import neo4j from 'neo4j-driver';

const typeDefs = `#graphql
  type Movie @node {
    id: ID! @id
    title: String!
    actors: [Person!]! @relationship(type: "ACTED_IN", direction: IN)
  }

  type Person @node {
    id: ID! @id
    name: String!
    movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
  }
`;

const driver = neo4j.driver(
  process.env.NEO4J_URI,
  neo4j.auth.basic(process.env.NEO4J_USERNAME, process.env.NEO4J_PASSWORD)
);

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

// getSchema() first — assertIndexesAndConstraints() throws if called before it
const schema = await neoSchema.getSchema();

// v7: validates @fulltext/@vector indexes only; creates nothing (no `options.create` in v7)
try {
  await neoSchema.assertIndexesAndConstraints();
} catch (e) {
  console.error(e.message); // e.g. Missing @fulltext index 'ProductName' on Node 'Product'
  process.exit(1);
}

const server = new ApolloServer({ schema });

const { url } = await startStandaloneServer(server, {
  context: async ({ req }) => ({ token: req.headers.authorization }),
  listen: { port: 4000 },
});

Key Directives

@node (v7 required)

type Product @node {
  id: ID! @id
  name: String!
}

# Custom label (default = type name)
type Article @node(labels: ["Post", "Content"]) {
  title: String!
}

@relationship — Full Syntax

type Person @node {
  # direction: OUT = (this)-[:KNOWS]->(other)
  friends: [Person!]! @relationship(type: "KNOWS", direction: OUT)

  # direction: IN = (other)-[:ACTED_IN]->(this)
  actedIn: [Movie!]! @relationship(type: "ACTED_IN", direction: IN)

  # direction accepts only IN | OUT. Undirected querying = queryDirection
  # v7: DIRECTED (default) | UNDIRECTED; v5: DEFAULT_DIRECTED | DEFAULT_UNDIRECTED | DIRECTED_ONLY | UNDIRECTED_ONLY
  colleagues: [Person!]! @relationship(type: "COLLEAGUE_OF", direction: OUT, queryDirection: UNDIRECTED)

  # Relationship with properties — reference an @relationshipProperties type
  reviews: [Movie!]! @relationship(type: "REVIEWED", direction: OUT, properties: "ReviewedProps")
}

type ReviewedProps @relationshipProperties {  # type, not interface — interface fails schema build
  rating: Int!
  date: Date
}

Querying Relationship Properties — Connection API

For each relationship with properties:, a {field}Connection field is auto-generated. Access rel properties via actorsConnection.edges.properties, not via actors:

query {
  movies(where: { title: { eq: "The Matrix" } }) {
    title
    actorsConnection {
      edges {
        properties { role }   # maps to @relationshipProperties type
        node { name }
      }
    }
  }
}

@cypher — Custom Resolver

type Person @node {
  name: String!

  # columnName must exactly match the R
Полный SKILL.md на GitHub

Установить neo4j-graphql-skill в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash
WebFetch

Вложенные файлы

README.mdreferences/ogm.mdreferences/search-directives.md

FAQ

Что делает скилл neo4j-graphql-skill?

Build and configure a GraphQL API backed by Neo4j using @neo4j/graphql v7 (current) or v5 (LTS). Covers Neo4jGraphQL constructor, getSchema(), assertIndexesAndConstraints(), type definitions with @node, @relationship (IN/OUT, queryDirection), @cypher for custom resolvers, @authorization/@authentication for JWT/JWKS security, auto-generated queries/mutations, OGM programmatic access, subscriptions via CDC, and Apollo Federation. Use when writing typeDefs, securing fields, or wiring Neo4j to Apollo Server. Does NOT handle raw Cypher outside resolvers — use neo4j-cypher-skill. Does NOT cover Spring Data Neo4j entity mapping — use neo4j-spring-data-skill.

Как установить скилл neo4j-graphql-skill?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл neo4j-graphql-skill запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить neo4j-graphql-skill с