Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics on ogm #421

Closed
wants to merge 4 commits into from
Closed

Generics on ogm #421

wants to merge 4 commits into from

Conversation

danstarns
Copy link
Contributor

Description

Simple addition allows the use of a generic when calling .model on the OGM. This enables users to define their own types for each method, for example:

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

class MyCustomModel {
    constructor() {}

    async find(args: { where: { id: string } }): Promise<{ id: string; password: string }[]> {
        return [];
    }
}

const User = ogm.model<MyCustomModel>("User");

Then you'd get autocomplete like this:

1866d8b6f86e813416eade443d2b0208

Tech-savvy users could use a graphql code gen and have full autocomplete via using this method.

Issue

Related to #174

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • TCK tests have been updated
  • Integration tests have been updated
  • Example applications have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant