0
votes

For my nodejs app, I am using neo4j 3.2.0 community edition as a primary database and I want to create a Graphql APIserver and establish connection between this api server and neo4j db. I looked into the official graphql-neo4j-graph-database-integration (https://github.com/neo4j-graphql/neo4j-graphql), but according to its documentation it says that this works only on 3.0 and 3.1.

So, can anyone please explain how can I establish connection between the graphql server and neo4j db (3.2.0 community edition) ?

PS. I even looked into apollo express-graphql server and their documentation,I understood how the graphql endpoint can be used in an express web server if i create one, but what I am unable to grasp is even if I create an apollo express-graphql server, how am I supposed to integrate it with neo4j as graphql does not seem to have connector present for neo4j ?

Please let me know if I am missing something here regarding the architecture of graphql with neo4j and express in nodejs environment. (Thanks in Advance)

1

1 Answers

0
votes

The neo4j-graphql library allows you to embed Cypher queries to be used as GraphQL resolvers, which indeed is very helpful when developing a Neo4j backed GraphQL server. But, you don't actually need it to achieve the same result. Instead, all you have to do is write resolvers that talk to Neo4j yourself, and as long as your platform (Node.js) has the appropriate drivers (and it does) - you're good to go.

E.g. a very simple schema, defined programmatically (i.e. not via IDL) could look like this:

let schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      numberOfRegisteredUsers: {
        type: GraphQLInt,
        resolve: function() {
          return neo4j.queryForTheNumberOfUsers(); //this is your custom resolution logic
        }
      }
    }
  })
});

As you can see, apart from the usual Neo4j driver, you don't need anything extra. No special connectors or any GraphQL-specific bits.