OGM

constructor

Returns an OGM instance.

Takes an input object as a parameter, which is then passed to the Neo4jGraphQL constructor. Supported options are listed in the documentation for Neo4jGraphQL.

Example

const ogm = new OGM({
    typeDefs,
});

init

Asynchronous method to initialize the OGM. Internally, calls Neo4jGraphQL.getSchema() to generate a GraphQL schema, and stores the result. Initializes any models which have been created before this execution, and will throw an error if any of them are invalid.

model

Returns a Model instance matching the passed in name, or (if the OGM has been initialized) throws an Error if one can’t be found.

Accepts a single argument name of type string.

Example

For the following type definitions:

type User {
    username: String!
}

The following would successfully return a Model instance:

const User = ogm.model("User");

The following would throw an Error:

const User = ogm.model("NotFound");