I am using the official Neo4j Javascript driver to connect with my database. I want to run queries directly from .cypher files because writing them as strings is much more error-prone.
I don't want to read the file using fs, as it would consume unnecessary resources. I want to import the file as I do with a JSON file (at compile time)
How can I do that?
You could use the approach that is used in graphacademy for test fixtures.
There a js file is imported that holds the fixtures as javascript objects.
You can do the same just with Cypher queries.
See:
https://github.com/neo4j-graphacademy/app-nodejs/blob/main/test/fixtures/movies.js
import { goodfellas, popular } from '../../test/fixtures/movies.js'
https://github.com/neo4j-graphacademy/app-nodejs/blob/main/src/services/movie.service.js#L1