Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-04-2021 09:33 PM
My application has 3 data sources: two neo4j graph dbs at different servers and a Postgres db.
The neo4j-graphql-js
allows to create a single neo4j.driver
that holds the neo4j server and authentication details. One can handle multiple dbs (multi-tenancy) from the same neo4j server by specifying the appropriate db name in context.neo4jDatabase
How can I connect to two different neo4j servers, which would require two neo4j.driver
? What are the best practices for this scenario? One option is to write custom resolvers for one or both the neo4j servers.
Hope this gets covered in the livebook Fullstack GraphQL Applications with GRANDstack.
05-07-2021 12:42 PM
Since the driver instance is passed in the context function at query time you could have some logic in the context function that determines which driver instance to return. This won't necessarily work if you have a single GraphQL request that needs to resolve data from two separate Neo4j instances, so for that case the better option is as you suggest to implement resolvers for one of the Neo4j instances.
This also sounds like a potential use case for GraphQL schema stitching or schema delegation so those might be options to explore as well. There's an example of using schema stitching with neo4j-graphql-js here.
This topic is not covered in the book you mention as resolving GraphQL operations against multiple Neo4j DBMS instances is not a common use case that comes up.
05-09-2021 07:57 PM
Thanks William.
GraphQL schema stitching is more applicable for my case.
All the sessions of the conference are now available online