Hi I am having massive trouble to do an apparently very simple thing:
NestJS + GraphQL + Neo4J
The issue: the custom directive of neo4j generated from graphql schema are unknown to any framework from the outside.
I see that many other people have struggled with that and can not find any example or doc how to find it.
Here is my generated schema out of neo4j:
interface ActedInProperties @relationshipProperties {
roles: [String]!
}
type Movie {
genre: String!
peopleActedIn: [Person!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedInProperties")
peopleDirected: [Person!]! @relationship(type: "DIRECTED", direction: IN)
peopleProduced: [Person!]! @relationship(type: "PRODUCED", direction: IN)
peopleReviewed: [Person!]! @relationship(type: "REVIEWED", direction: IN, properties: "ReviewedProperties")
peopleWrote: [Person!]! @relationship(type: "WROTE", direction: IN)
released: BigInt!
tagline: String!
title: String!
}
type Person {
actedInMovies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedInProperties")
born: BigInt!
directedMovies: [Movie!]! @relationship(type: "DIRECTED", direction: OUT)
followsPeople: [Person!]! @relationship(type: "FOLLOWS", direction: OUT)
name: String!
peopleFollows: [Person!]! @relationship(type: "FOLLOWS", direction: IN)
producedMovies: [Movie!]! @relationship(type: "PRODUCED", direction: OUT)
reviewedMovies: [Movie!]! @relationship(type: "REVIEWED", direction: OUT, properties: "ReviewedProperties")
wroteMovies: [Movie!]! @relationship(type: "WROTE", direction: OUT)
}
interface ReviewedProperties @relationshipProperties {
rating: BigInt!
summary: String!
}
Now I want just to spin up a nestjs stack using this schema and generate the types for it, so I do something like:
import { readFileSync } from 'fs';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { GraphQLModule } from '@nestjs/graphql';
import { Neo4jGraphQL } from '@neo4j/graphql';
const path = `${process.cwd()}/apps/be/src/app/schema/generatedGraphql.ts`;
const typeDefs = readFileSync(
'apps/be/src/app/schema/generatedSchemaRel.graphql',
'utf-8'
);
// how to combine this specific schema with nestjs ?
// const augmentedSchema = makeAugmentedSchema({ typeDefs });
// here is the newest way according to docu
const neo4jGraphQL = new Neo4jGraphQL({ typeDefs });
let schema;
neo4jGraphQL.getSchema().then((s)=>{
schema = s;
});
const graphQLModule = GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
schema, // how do I propaget the neo4j specific schema to nestjs?
typePaths: ['./**/*.graphql'],
definitions: {
path,
outputAs: 'class',
},
});
@Module({
imports: [graphQLModule],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
The error is always the same, the @relationship directive is just unknown to nestjs and there is no way to configure it easilly.
Thanks in advance for your help.