-
Notifications
You must be signed in to change notification settings - Fork 13
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
Labels // Get Labels for Instance #21
Comments
Hello, I'm glad that you're enjoying Neogma so far!
Yes, this is the only way.
You would have to repeat everything, for example use the same object/functions for each model. |
Thanks for the quick reply! I think the easiest solution would be an instance method to return the labels for a model. So, here you already have access to the labels from the record (node.labels). So you could store it by assigning node.labels to a instance property here either as a public property, .e.g Doing so would allow me to use one model to retrieve results from the backend and then administer different tenants on the graphql layer by checking the labels. |
Just a question so I can understand this more, would this implementation offer more than just creating a method which calls the |
Yes. So it's more than the labels returned by the schema. It's the actual labels used by the returned result node. That way I can define the model with one label (Person) but have it also return any other labels on that person. This way I don't have to define overlapping and redundant models. I can define just the Person and then deal with different use cases in the GraphQL layer -- ie if person has the label "Admin" I could filter the sub graph |
Please let me know if my implementation covers your needs. buildFromRecord doc. Deployed in 1.9.0. |
Enjoying your package so far. I'm trying to implement a schema where I have different tenants -- (i.e., Person, Person:Admin). In the past, I've used multiple labels and added instance methods on the object to return the labels so I could handle each tenant differently.
How could one go about doing that with Neogma? Ideally, the model could return all the labels from the database, but it doesn't currently. Should I define two different Models -- i.e. a "Person" that just has the sole label, and then an "Admin" that has both labels ("Person", "Admin"). Would relations defined on the base "Person" extend to the "Admin" or would I have to duplicate everything?
The text was updated successfully, but these errors were encountered: