# Integrating Neo4j with Nestjs and Graphql

**URL:** <https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053>\
**Category:** Drivers & Stacks\
**Tags:** migrated\
**Created:** [February 12, 2020, 7:17am UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053 "2020-02-12T07:17:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mail2michaelenn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mail2michaelenn/32/2762_2.png) [@mail2michaelenn](https://community.neo4j.com/u/mail2michaelenn)\
**Post date:** [February 12, 2020, 7:17am UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053/1 "2020-02-12T07:17:01Z")

</div>

neo4j-graphql-js @relation directive produce a @relation undefined error in nestjs graphql generate-typings:  
Using the following:  
type Author {  
id: ID!  
name: String!  
posts: [Post] @relation(name: "REGISTERED", direction: "OUT")  
}  
with  
const definitionsFactory = new GraphQLDefinitionsFactory();  
definitionsFactory.generate({  
typePaths: ['./src/\*\*/\*.graphql'],  
path: join(process.cwd(), 'src/schema.graphql.ts'),  
outputAs: 'class',  
watch: true,  
});

to produce an auto-generated schema result in this error:  
(node:181608) UnhandledPromiseRejectionWarning: Error: Unknown directive "relation".  
at assertValidSDL (C:\Genysis-Microservices\[registry.genysis.com](http://registry.genysis.com)\node\_modules\graphql\validation\validate.js:108:11)  
at Object.buildASTSchema (C:\Genysis-Microservices\[registry.genysis.com](http://registry.genysis.com)\node\_modules\graphql\utilities\buildASTSchema.js:71:34)  
at Object.buildSchemaFromTypeDefinitions (C:\Genysis-Microservices\[registry.genysis.com](http://registry.genysis.com)\node\_modules\graphql-tools\src\generate\buildSchemaFromTypeDefinitions.ts:43:32)

It would appear that we have to define the directives before we can use them in GraphQLDefinitionsFactory()....if this is the case how would we handle the directives of neo4j-graphql-js augmented schema?

---

<div class="post-metadata">

**Author:** ![Minimalist](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@Minimalist](https://community.neo4j.com/u/Minimalist)\
**Post date:** [July 13, 2022, 8:55am UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053/2 "2022-07-13T08:55:08Z")

</div>

Hi I am facing a similar issue as you did. In my case I just want to generate the types from a given neo4j schema to use them in graphql, here is my question [https://community.neo4j.com/t5/drivers-stacks/neo4j-nestjs-graphql-directives-relashionship-unknown-and-not/m-p/57570](https://community.neo4j.com/t5/drivers-stacks/neo4j-nestjs-graphql-directives-relashionship-unknown-and-not/m-p/57570)

So did you manage it to combine the neo specific schema with nestjs?

Thanks in advance...

---

<div class="post-metadata">

**Author:** ![mail2michaelenn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mail2michaelenn/32/2762_2.png) [@mail2michaelenn](https://community.neo4j.com/u/mail2michaelenn)\
**Post date:** [July 19, 2023, 12:47am UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053/3 "2023-07-19T00:47:49Z")

</div>

Incredible.....I have not been following the community for lack of activity. i find it very interesting that a question I ask almost 3 years ago we still struggle with. I have just revisited this issue and found your answer a year ago interesting. Did you improve on it? I would be interested to know. I found the new directives in neo4jGraphql V3 interesting and would really like to use them with Nest. I have been ignoring the neo4jGraphql lib for the plain neo4j-driver but with a solution to this problem it may get new life in nest.

---

<div class="post-metadata">

**Author:** ![mat](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mat/32/21506_2.png) [@mat](https://community.neo4j.com/u/mat)\
**Post date:** [August 7, 2023, 2:42am UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053/4 "2023-08-07T02:42:41Z")

</div>

I currently have accomplished this and would be interested in helping you get it setup. What seems to be the issue getting it up and running?

---

<div class="post-metadata">

**Author:** ![mail2michaelenn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mail2michaelenn/32/2762_2.png) [@mail2michaelenn](https://community.neo4j.com/u/mail2michaelenn)\
**Post date:** [August 7, 2023, 5:39pm UTC](https://community.neo4j.com/t/integrating-neo4j-with-nestjs-and-graphql/60053/5 "2023-08-07T17:39:46Z")

</div>

Hey Matt.....this is great news. I have revamp my strategy many times.  
My most recent strategy follows this pattern: using nestjs v11/apollo server V4/neo4jGraphql V3 in a monorepo with Federation..  
Here I have a gateway and let's say a wallet microservice. I also have a neo4j dynamic module that creates a connection to the database, AND I also have a dynamic graphql module that launches the startStandAloneServer. I have not fully tested this as yet but I can post the relevant code.  
My main problems relates to launching the v4 apollo server and that the neo4j directives are compatible with Nest and apollo v4.
