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

Class Builder Script for OGM #4624

Open
inf3rnus opened this issue Jan 30, 2024 · 1 comment
Open

Class Builder Script for OGM #4624

inf3rnus opened this issue Jan 30, 2024 · 1 comment
Labels
feature request New feature or request ogm

Comments

@inf3rnus
Copy link

inf3rnus commented Jan 30, 2024

Is your feature request related to a problem? Please describe.
Nope

Describe the solution you'd like
I want a helper script that generates classes for each node type so that Intellisense's autocomplete can be leveraged.

Then on the base class, add a number of convenient methods for connecting two nodes, creating a single node, etc.

Could be inferred from the schema.

Basically the thought is that it'd be a script, or method you run that does this and spits out the code into a file somewhere.

e.g. and this is a rough example, in the middle of writing code that's similar to what I'm describing, and I haven't run it yet, but to get a sense of what I mean:

class Node {
  constructor(props) {
    this.props = props;
  }

  asArgs() {
    return {
      type: this.constructor.name,
      props: this.props
    };
  }

  put() {
    return graph.node.put({
      type: this.constructor.name,
      props: this.props
    });
  }

  putAndConnect(toNode, edgeProps) {
    return graph.node.putAndConnect({
      from: this.asArgs(),
      edge: edgeProps,
      to: toNode.asArgs()
    });
  }
}

class Metric extends Node {
  constructor({
    props: {
      name,
      source,
      description,
    }
  }) {
    super({
      name,
      source,
      description,
    });
  }
}

Describe alternatives you've considered
Writing this myself!

@inf3rnus inf3rnus added the feature request New feature or request label Jan 30, 2024
@inf3rnus
Copy link
Author

Would be a killer feature IMO, way cooler than having to manually specify types.

@angrykoala angrykoala added the ogm label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request ogm
Projects
None yet
Development

No branches or pull requests

2 participants