neo4jgraphqlneo4j-graphql-jsneo4j-graphql-library

Neo4j GraphQL library First Development approach


I'm considering using the Neo4j GraphQL library and have the following question - am I correct in understanding that I can use Neo4j GraphQL Type definitions to automatically generate not only the Neo4j GraphQL API but also the schema for my Neo4j database itself?

I'd like to use Neo4j GraphQL Type definitions as my entry point to both - DB schema and GraphQL API automatic creation.

In the documentation for the Neo4j GraphQL library, I see the ability to declare @Id, indexes, and constraints. But how about initial data - for example, if I need to declare a Movie type using Type definitions, can I also immediately add (CREATE) 10 movies with specific predefined names? Can I create such initial data, such as nodes, relationships, and properties, directly in Neo4j GraphQL Type definitions? If so, please guide me on how to do it.


Solution

  • No, you must perform explicit mutations to populate the database.

    The Neo4j GraphQL Library type definitions are used to define the mapping between your input/output data and your graph data model. And the directives are used to further modify the behavior of queries or mutations (e.g. to automate the population of specific fields). But those facilities are not able to prepopulate the database.