How to integrate neo4j-graphql-js into nestjs w/Graphql

I am experimenting with Nestjs, graphql, and neo4j-graphql with augmented schema. I am interested if anyone doing any work in this area. The main challenge I am having relates to neo4j-graphql-js and the code-first concept. So from my understanding neo4j-graphql-js in based on the Schema-first approach...is this correct? and if this is so what kind of workaround can be done to fit in the code-first approach. If this is not so...are there any available example of how this works.

I'm not sure what you mean by code first approach, can you clarify?

yes with neo4j-graphql-js, generally you start by coming up with a GraphQL schema / set of typedefs and resolvers. The resolvers can of course be JS code, but the typedefs aren't.

There are a number of folks doing work in this area but it'd help if you could narrow down what you're trying to do, what you've tried, and what you want to do.

The Nestjs graphql docs(https://docs.nestjs.com/graphql/quick-start) speaks to Schema First and Code First. The code first (resolver first) approach uses the type-graphql library to generate the schema from the resolvers....apparently this approach was introduced to solve scalability and single-source of truth for the schema. I am looking at Christian Lutz response to a similar question (https://stackoverflow.com/questions/53544876/how-to-integrate-neo4j-database-nestjs-framework-and-graphql) where he suggested using Nest Interceptor with the schema first approach. What I am trying to do is implement the code first approach using type-graphql and neo4j-graphql. In essence I want to go from my standard Nest/REST approach of xyz-controller --> xyz-service-->neo4j-service to a Nest/graphql/neo4j structure using the code first approach.

I am still not 100% sure I'm following, and I may just not be the right person to answer this.

On the note of generating the schema, this can be done from an existing Neo4j Database: https://blog.grandstack.io/inferring-graphql-type-definitions-from-an-existing-neo4j-database-dadca2138b25 but "generating the schema from the resolvers" doesn't fully parse for me and I can't advise.

Hey @mail2michaelennis -

You can do "code first GraphQL" with neo4j-graphql.js by passing a GraphQL schema object to makeAugmentedSchema or augmentSchema. I'm not too familiar with Nest, but if you are using it to create a GraphQL schema object, you can pass that to makeAugmentedSchema from neo4j-graphql.js to add the auto-generated resolvers, instead of SDL type definitions:

const schema = makeAugmentedSchema({schema: mySchema})

In that stackoverflow answer it looks like they are passing augmentSchema to a transformSchema step.

Yes....I can see that if we have a schema created we can pass it through the augmentSchema function. The problem is in the Nest version it's not clear how the schema (schema.gql) is created. Apparently the type-graphql library builds it on startup of the app but this is not clear. I will test this view to see it it works....Thanks for the input.

Thanks David...I agree it's not quite clear what's going on...so I am going to do some trial and error.

-Michael